Hi,
I use TabSheet with lazy loading tabs as mentioned in the docs
I store the index of the last selected tab in session in order to restore this selection if the view is shown again.
Unfortunately, after lazy initializing the tab with the stored index id, also the first tab is initialized, but thankfully the content is not switched. Surprisingly, the order of those lazy initialising is
- first the stored tab index (correct)
- then the tab #0 (wrong)
See the following MRE:
var tab1 = new Tab("Tab 1");
var tab2 = new Tab("Tab 2");
var tab3 = new Tab("Tab 3");
TabSheet tabSheet = new TabSheet();
tabSheet.addThemeVariants(TabSheetVariant.LUMO_TABS_CENTERED);
tabSheet.setSizeFull();
tabSheet.add(tab1, new LazyTabComponent(() -> {log.debug("tab1"); return new Div("Tab 1"); }));
tabSheet.add(tab2, new LazyTabComponent(() -> {log.debug("tab2"); return new Div("Tab 2"); }));
tabSheet.add(tab3, new LazyTabComponent(() -> {log.debug("tab3"); return new Div("Tab 3"); }));
tabSheet.setSelectedIndex(2);
add(tabSheet);
The logs shows the order of execution as
DEBUG de.hub28.steel42.ui.TestView tab3
DEBUG de.hub28.steel42.ui.TestView tab1
Is this a bug or how can I prevent the initializing of tab #0 ?