flutter-plugins
flutter-plugins copied to clipboard
[desktop_webview_window]: addOnUrlRequestCallback not triggered on SPA (e.g. React) client-side route changes
Hi, thank you for this helpful plugin!
I'm using desktop_webview_window in my Flutter Linux app to embed a webview. The addOnUrlRequestCallback works fine for traditional full-page navigations, but it's not triggered when navigating within a Single Page Application (SPA) such as a React app that uses client-side routing (e.g. React Router or Next.js).
Steps to Reproduce:
- Load a React-based SPA (e.g. a local or deployed React app) in the webview.
- Use the app's navigation (e.g. Use navigate or clicking on a <Link> element to route to another page).
- Observe that addOnUrlRequestCallback is not called on these URL changes.
Expected Behavior:
- The callback should also be triggered when the URL changes due to client-side routing in SPAs, not just for full-page navigations.
- Alternatively, we could have a new dedicated callback specifically for detecting URL changes in SPA apps.
Actual Behavior: addOnUrlRequestCallback is only triggered for full page loads (e.g. window.location.href = '...') and not for history API-based routing (history.pushState, replaceState), which is commonly used in SPAs.
Environment: OS: Linux Flutter version: 3.29.2 Plugin version: ^0.2.3
I'd like to work on this issue. Please assign it to me.
I’ll implement support for detecting SPA-style URL changes natively on the Linux GTK side and add a new callback/update callback through the method channel to notify Flutter about those changes.
Happy to contribute and open a PR for this enhancement.