kweb-core icon indicating copy to clipboard operation
kweb-core copied to clipboard

Support browser history in routing

Open sanity opened this issue 8 years ago • 6 comments

Currently routing doesn't fully support browser history functionality, like handling the back button. See routing.kt.

sanity avatar May 31 '17 02:05 sanity

We can add a window.popstate event in JS to send a websockets message with the current URL. The question now becomes how to (a) get the client's WebBrowser and its url, and (b) how to set url in such a way that it won't fire a pushState back onto the client.

wooky avatar Feb 17 '20 22:02 wooky

(a) get the client's WebBrowser and it

Yes, this might require some rearranging, we could possibly use a handler in RemoteClientState to handle the back-button event, although that feels a bit kludgy.

(b) how to set url in such a way that it won't fire a pushState back onto the client.

We might need to add a boolean flag to url to record whether it was set on the client or the server, this can be used to ensure that a pushState is only sent if the URL change is server-initiated.

sanity avatar Feb 18 '20 01:02 sanity

I decided to have a potshot at the problem because it's causing a double page reload for us when using the browser forward/back buttons. My first stop is to remove https://github.com/kwebio/kweb-core/blame/720b1d241411854eb27dc30b869a89d2982c2970/src/main/resources/kweb/kweb_bootstrap.js#L275 and see what's affected

alkoclick avatar Sep 12 '20 13:09 alkoclick

Thanks @alkoclick, I've been digging through blame logs to try to remember the purpose of that, but no luck. Hopefully it's unnecessary.

sanity avatar Sep 12 '20 17:09 sanity

Yeah, I removed and it and run a custom build without it today, it causes no difference for us (and in fact fixes a bunch of problems). I was going to actually test it on one of the test demos as well but my laptop died so tough luck :/

alkoclick avatar Sep 12 '20 21:09 alkoclick

I can remove it and verify it on a few projects?

sanity avatar Sep 13 '20 13:09 sanity

I think this is done, please reopen if not.

sanity avatar Oct 22 '22 16:10 sanity