File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/main/java/com/flowingcode/vaadin/addons/demo Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ public class TabbedDemo extends VerticalLayout implements RouterLayout {
5353 private static final Logger logger = LoggerFactory .getLogger (TabbedDemo .class );
5454
5555 private static final int MOBILE_DEVICE_BREAKPOINT_WIDTH = 768 ;
56+ private boolean autoVisibility ;
5657 private EnhancedRouteTabs tabs ;
5758 private HorizontalLayout footer ;
5859 private SplitLayoutDemo currentLayout ;
@@ -138,6 +139,7 @@ public void addDemo(Component demo) {
138139 @ Deprecated
139140 public void addDemo (Component demo , String label , String sourceCodeUrl ) {
140141 tabs .addLegacyTab (label , demo );
142+ updateVisibility ();
141143 }
142144
143145 /**
@@ -151,6 +153,22 @@ public void addDemo(Class<? extends Component> clazz, String label) {
151153 throw new IllegalArgumentException (clazz + " must be annotated as Route" );
152154 }
153155 tabs .add (label , clazz );
156+ updateVisibility ();
157+ }
158+
159+ private void updateVisibility () {
160+ if (autoVisibility ) {
161+ tabs .setVisible (tabs .getContent ().getTabCount () > 1 );
162+ }
163+ }
164+
165+ /**
166+ * Sets the autovisibility mode. When autovisibility is enabled, the tabs component is hidden
167+ * unless it contains two or more tabs.
168+ */
169+ public void setAutoVisibility (boolean autoVisibility ) {
170+ this .autoVisibility = autoVisibility ;
171+ updateVisibility ();
154172 }
155173
156174 /**
You can’t perform that action at this time.
0 commit comments