How to start with a collapsed sidemenu after login

Hi.

I read about sidemenu, drawer… all works fine,
but I cannot get the sidemenu beeing collapsed when a user logs in.
It is expanded automatically each time after a new login.

Regards
Roland

If you want the sideMenu to always be collapsed after the user login, then add a few lines in the MainScreen controller::

@Subscribe
    public void onAfterShow(AfterShowEvent event) {
        screenTools.openDefaultScreen(
                UiControllerUtils.getScreenContext(this).getScreens());

        screenTools.handleRedirect();
        
//Collapse sideMenu if expanded
        if (!drawer.isCollapsed()) {
            drawer.toggle();
        }
    }

If you need to remember the state of the menu for the user and restore after logging into the application - use a similar approach and the UserSettingService to save and read the state of the MainScreen.

2 Likes