Tab lost after reload browser

my page have 3 components ‘Tabs’. tab1 tab2 and tab3

when user works in Tab 2 or 3 and reload browser, then he continues only on Tab 1.

What can I do to setting Tab? I want if user worked on Tab 2 after reload browser he continued on Tab 2.

private static Tab getAvailableTabs() {
final List tabs = new ArrayList<>(4);
tabs.add(createTab(VaadinIcon.TABLE, Logic1, Logic1.class));
tabs.add(createTab(VaadinIcon.TABLE, Logic2, Logic2.class));
tabs.add(createTab(VaadinIcon.TABLE, Logic3, Logic3.class));
String contextPath = VaadinServlet.getCurrent().getServletContext().getContextPath();
final Tab logoutTab = createTab(createLogoutLink(contextPath));
return tabs.toArray(new Tab[0]

You could save the ‘selected’ Tab in the containing component and switch to the Tab in a onAttach listener.

Tab selected;
tabs.addSelectedChangeListener(listener -> this.selected = listener.getSelectedTab());
tabs.addAttachListener(listener -> tabs.setSelectedTab(this.selected));

That assumes you’re using @PreserveOnRefresh and not issuing a fresh UI.