0

I'm working on a Maven, Vaadin with Designer and i can not resolve why my code is still showing me "test" and "test2" because through the testView2.setVisible(false) the "test2" label should be hidden. Here is all relevant code. Hope anyone can help.

TestView.java

@Tag("test-view")
@HtmlImport("src/views/kunde/test-view.html")
@Route("test")
public class TestView extends PolymerTemplate<TestView.TestViewModel> {

@Id("testView2")
private TestView2 testView2;

    public TestView() {
         testView2.setVisible(false);
    }

    public interface TestViewModel extends TemplateModel {
    }
}

test-view.html

<dom-module id="test-view"> <template>
<style include="shared-styles">
:host {
    display: block;
}
</style>
<div>
    <label>Label</label>
</div>
<test-view-2 id="testView2"></test-view-2> 
</template> <script>
        class TestView extends Polymer.Element {
            static get is() {
                return 'test-view';
            }
            static get properties() {
                return {
                    // Declare your properties here.
                };
            }
        }
        customElements.define(TestView.is, TestView);
    </script> </dom-module>

test-view-2.html

<dom-module id="test-view-2">
<template>
<style include="shared-styles">
        :host {
            display: block;
        }
    </style>
<div>
    <label>test2</label>
</div>
</template>
<script>
    class TestView2 extends Polymer.Element {
        static get is() {
            return 'test-view-2';
        }
        static get properties() {
            return {
                // Declare your properties here.
            };
        }
    }
    customElements.define(TestView2.is, TestView2);
</script>
</dom-module>
cyflex
  • 15
  • 2

1 Answers1

2

The reason is most probably because Flow uses the hidden HTML attribute when using setVisible(false). But because Designer by default adds :host { display: block; } to a design, and https://meowni.ca/hidden.is.a.lie.html, the design will not obey the hidden attribute.

You can work around this by adding the following styles manually to your design:

:host([hidden]) {
  display: none !important;
}
Jouni
  • 2,830
  • 15
  • 12