Side menu item selected state is lost on page reload

Hi,
In side menu when attribute selectOnClick=“true” - when I click side menu item it is marked as selected and selected style is applied but on page reload it looses this state and current screen is not selected in side menu.
Is there any other property that I have to set or other solution so the side menu doesn’t lose current selected item style?

Thank you!

Hello!

Looks like a bug, thank you for reporting an issue! Created an issue: jmix-framework/jmix#742.

There is a workaround:

@Autowired
private SideMenu sideMenu;

@EventListener
public void refreshListener(UIRefreshEvent event) {
    if (sideMenu.getSelectedItem() != null) {
        SideMenu.MenuItem selectedItem = sideMenu.getSelectedItem();

        // select any item to deselect previous
        sideMenu.setSelectedItem(sideMenu.getMenuItems().get(0));

        // select actual item
        sideMenu.setSelectedItem(selectedItem);
    }
}

Thank you for your answer!
I try it and it works as I expect!

Hi I saw that you add the bug fix in last release 1.2.4, but I think selecting still doesn’t work as it suppose to work.
If I close window it still stays selected in side menu. I think selecting should be connected to current open screen(if it has screen Id in side menu).
Also if I switch between open tabs in side menu selected screen is not changing.

Hi, menu item does not change its state due to SideMenu and main TabSheet are separated components.

But you can implement this feature in your project, take a look at: