Closed Dr-Irv closed 1 year ago
It seems that if I call navigate()
in the on_navigate()
function, it works, i.e.,
def on_navigate(state: State, page_name: str) -> str:
state.last_request = page_name
if page_name == "page2" and not allow_page2:
notify(state, "error", "cannot go to page2 before page1")
navigate(state, "page1")
return "page1"
return page_name
But I don't know if that's "safe" from a taipy perspective. If so, then the docs should be updated accordingly.
It is a great workaround for the moment to solve your issue. I agree, either way, the doc has to change or it should correctly redirect the user to the correct page. Having the on_navigate()
correctly redirects the user like in the current documentation seems to me the better way.
So the problem is that if the user requests /page2 but on_navigate blocks page2, we need to reflect the real page shown in the URL bar.
Description If you use
on_navigate()
to change the page, the URL in the browser is not updated to the correct place.How to reproduce
When you start the app, the URL shown in the browser is
http://127.0.0.1:5000/page1
. When you click onpage2
, it should switch to show that URL. The content does switch, but the URL doesn't change. Also, the navbar doesn't update either (but that's probably because the URL is wrong).Expected behavior The URL in the browser should change to the requested page.
Screenshots At beginning of app, it looks like this:
If you click on "page2", you get this. Note that the content is correct, but the URL at the top is wrong.
Runtime environment Please specify relevant indications.