NemesisRE / kiosk-mode

🙈 Hides the Home Assistant header and/or sidebar
MIT License
368 stars 14 forks source link

Fix hide_sidebar option in Companion App #276

Closed elchininet closed 2 weeks ago

elchininet commented 2 weeks ago

When one opens and closes the sidebar, there is a logic behind to manage the Navigation Drawer and its focus trap.

If one hides the sidebar and applies all the styling override that kiosk-modes applies, the logic to remove all the inert blockers from the screen and to set all the elements in a closed state is never executed. This is not a problem for those that set hide_sidebar globally in all the dashboards, but it is a problem if someone wants a dashboard without sidebar and navigates to it from a dashboard with it enabled, because in that moment the logic to close the sidebar is executed and as the sidebar never closes this provokes that it is impossible to interact with the interface.

In this pull request a small fix has been introduced. Before hiding the sidebar, we are checking if the type of the mc-drawer element is modal (it occurs in mobile) and if its appContent has the inert property set in true (in those cases it is impossible to interact with the screen). If that is the case, then we wait for the MDCDrawer:closed event of the Navigation Drawer, and only after it is fired, we apply the styles to hide the sidebar. In the rest of the cases we hide the sidebar directly without waiting for this event.

Closes #275