-
Notifications
You must be signed in to change notification settings - Fork 344
fix: update current router URL on external location changes #2196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update current router URL on external location changes #2196
Conversation
|
I don't like this (overriding prototypes of builtins). What's the use case that you need a router for the extension? We could consider exposing enough of the router to the extension to then enable this. |
We could also use the new
I want to store state (current extension page, chart type, sorting params) in the URL. With a custom router it won't trigger a full page refresh. Adding (sub-)pages in the extension is also possible with a small adjustment of the router. Alternative solutions
Which one do you think is best? |
|
TIL the navigation API exists :) I think it's fine for Fava to only target recent enough browsers (although this only seems to have been in Firefox, my main browser, since the latest version). I guess listening for the navigate event would already fix the problem you are seeing (as you hopefully have a recent browser) and "upgrade browser" is just as good a bugfix or better than "upgrade fava". However, I'd rather want to improve the APIs for extensions here so that an extension does not have to bring their own router... Will have to think on what that might have to entail, suggestions welcome as well. PS: I have the feeling that the navigation API might make #2075 actually feasible? |
Yep, I think it's fine if it only works in the latest browser. The bug is merely an inconvenience, but it doesn't prevent users from using the extension.
I think it's great to have flexibility in the choice of framework (React, Svelte, Vue, etc.), and router. Some libraries (e.g. nuqs) are also convenient to use with a router. Which advantages do you see for users or developers if the extension utilizes Fava's router?
I think for #2075 we either need a way to skip storing the URL for the modal in the history, or don't change the URL at all when opening a modal. |
AFAICT, your extension has a couple of "sub-pages" and wants to keep a handful of state in query params. It just feels like having to bring a router for that is excessive. (in particular since these are intrusive libraries built around crap browser APIs and has evidenced here might interfere with Fava's router). |
|
I had to revert this as it broke back navigation. Seems like merged PRs cannot be re-opened, but we'll have to have another attempt at this... |
Ah sorry, I didn't notice that this breaks the back button. I just debugged it, the reason was that the navigate handler set the current URL, and then the popstate handler, which usually handles the back/forward button, did not detect any change in the URL, and therefore did not load the previous page. I updated the PR in #2209 to handle only |
When extension modules bring their own router (e.g.
react-routeror@tanstack/router), Fava's router is not aware of URL changes, and therouter.currentproperty will get stale.This is a problem when the global filters are changed (i.e. time, account or filter), because then Fava will redirect to that stale URL.
This PR subscribes to all navigation changes, and updates the
router.currentparam of the router.