Enable/disable kiosk mode does not work in same tab

When I specify an HABPanel URL without kiosk mode in the browser (by copy and paste into a new tab), e.g.
http://openhabianpi:8080/habpanel/index.html#/?kiosk=on
the page is correctly shown without header and menu.

When I paste
http://openhabianpi:8080/habpanel/index.html#/
into a new tab and directly after the page has been loaded
http://openhabianpi:8080/habpanel/index.html#/?kiosk=on
into the same tab, then only the header is gone. I can still pull open the menu from the side.

@ysc, is this a known thing that can somehow be worked around? I am building an android app with a flag to toggle kiosk mode and I can not get this to work.

Edit: this happens after upgrading HABPanel to the current snapshot from today.

@vbier for context, the kiosk mode was meant to be activated upon direct navigation only so a “kiosk-mode” dashboard has its own canonical URL you can set as your browser’s home page, not something that would be enabled later or from the main menu. So it could be a “bug” or “design limitation” depending on how you consider it :slight_smile:

Maybe you could rework the settings in HABPanelViewer so that the user has to specify the name (id) of a dashboard to display in kiosk mode, the way it was intended?
Then you simply would need to point the browser to:

<baseURL>/habpanel/index.html#/view/<dashboardId>?kiosk=on

Otherwise, this might be fixeable in HABPanel. The check to disable the drawer menu in kiosk mode is made here:

If I understand my own code correctly :roll_eyes: this code is reevaluted only when the menu has to be “refreshed”, i.e. when it has changed.

Okay, but it does not make a difference if i specify a panel or not. The problem persists when I use e.g.
https://openhabianpi:8443/habpanel/index.html#/view/Alarmpanel?kiosk=on
and
https://openhabianpi:8443/habpanel/index.html#/view/Alarmpanel

Edit: is there a way to force a menu refresh?

Edit2: The problem even occurs if you specify the two urls as bookmarks and then invoke one after the other in the same tab.

Forget it, I found a workaround. When kiosk mode changes, i load about:blank before loading
the url with the changed kiosk mode. This works.

Edit: But thanks for looking into this.

Ah I see, I think what’s happening was, if you navigate from one url to another with the same part before the ‘#’ (only the “fragment”, after the ‘#’ changes) the browser won’t perform a page refresh, and the stuff executed on page load doesn’t get executed again.

Thanks, that sounds reasonable.

Even if I found a workaround for me, this might still be a problem for others, as this also happens when you have the URL in the browser and just add/remove the kiosk flag. When you have the time and this is not too hard to fix it might be worth to look into this.

There is another problem with kiosk mode. If I go to the main habpanel page with kiosk mode enabled, then click on one of the panels, and then reload the page, kiosk mode is turned off.

@ysc, should I write an issue for this or is there some known workaround?

Err, normally you’re not supposed to be able to switch between dashboards or go to the menu when in kiosk mode since it’s designed to display a specific dashboard and disable all navigation :slight_smile:

Oh, come on. That’s essentially what you wrote last time. :wink: I had the hope maybe you forgot and tell me that there is a way to use kiosk mode like I thought it could be used: I have a dashboard with navigation buttons on it and only use kiosk mode in order to hide the title bar to get more screen real estate.

This works flawlessly until I hit the reload button.

Then I take it as a compliment for sticking to my guns :wink:

You’re right though about the navigation buttons, I forgot about those. The only way to enable kiosk mode is to append ?kiosk=on to the URL, which works with reloads as long as the URL doesn’t change, but that suffix is gone when you navigate. But that’s kind of expected and I’m not sure it’s really a bug :innocent:

What you could perhaps do as a workaround is handle the case specifically with HABPanelViewer since you have a menu entry to perform the reload:
(pseudo-code, not actual working code)

void reloadMenuClicked() {
    String url = webview.getUrl();
    boolean enableKioskMode = getSettings().getKioskMode();
    if (enableKioskMode && !url.endsWith("?kiosk=on")) {
        webview.loadUrl(url + "?kiosk=on");
    } else {
        webview.reload();
    }
}

The problem is that the url does no longer contain the kiosk part after pressing a navigation button.

I have removed the kiosk mode setting from my app in order to let users also use it on other UIs, which means I do no longer know if kiosk mode had been activated. Or even if the currently shown page is a habpanel page.