feat(desktop): expose navigation_handler in Config#5390
Open
FreeSynergy wants to merge 3 commits intoDioxusLabs:v0.6from
Open
feat(desktop): expose navigation_handler in Config#5390FreeSynergy wants to merge 3 commits intoDioxusLabs:v0.6from
FreeSynergy wants to merge 3 commits intoDioxusLabs:v0.6from
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The navigation handler in
dioxus-desktopis currently hardcoded inwebview.rs:This unconditionally opens every external
http/httpsURL in the system browser and blocks it in the WebView. Apps that intentionally embed web content (e.g. via<iframe>) have no way to opt out of this behavior or to allow specific URLs.Changes
config.rs: addsnavigation_handler: Option<Box<dyn Fn(String) -> bool + 'static>>field toConfig, initialized toNone.config.rs: addspub fn with_navigation_handler(mut self, handler: impl Fn(String) -> bool + 'static) -> Selfbuilder method with full doc-comment and example.webview.rs: ifcfg.navigation_handlerisSome, the closure delegates entirely to the user-supplied handler; otherwise the existing hardcoded behavior is preserved exactly.Non-breaking
When
with_navigation_handleris not called (the default), behavior is identical to before — no existing apps are affected.Example