refactor(core): add support to multiple webviews on a Tauri window#8280
Merged
lucasfernog merged 60 commits intodevfrom Jan 24, 2024
Merged
refactor(core): add support to multiple webviews on a Tauri window#8280lucasfernog merged 60 commits intodevfrom
lucasfernog merged 60 commits intodevfrom
Conversation
amrbashir
reviewed
Jan 23, 2024
amr-crabnebula
approved these changes
Jan 24, 2024
amrbashir
approved these changes
Jan 24, 2024
Contributor
|
Opened related issue |
|
Hi @lucasfernog, this is an awesome feature you've been working on. I've been playing around with it, and the only issue I've had is that it completely overlays the main tauri webview, so things can get hidden behind it. It makes things like managing drop downs and headers harder. Is it possible to position this webview so it sits under the main webview, enabling layering things on top? |
3 tasks
|
Is there an example of adding a new child webview to the main window when processing a command? |
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.
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___)Other information
Currently the Tauri's
Windowtype (both the Rust struct and JS class) are actually a mix of thetaoWindow and thewryWebview. In order to support multiple webviews on a given window, we actually have to split those types. This PR makes that change so nowWindowBuilderandWindowonly exposes the window APIs, and we addedWebviewBuilderandWebview.To create a window with a webview attached to it, I've added WindowBuilder::with_webview on the Rust side and WebviewWindow class on the JS side. This reduces the breaking changes on the JS side (which I think it's the most common way of using multiwindow on Tauri).
To add webviews to a window, Window::add_child was added. The API isn't finished yet, so I propose we either hide it for v2 or keep it behind an
unstablefeature flag. Specially the auto resize thing needs more work and configuration.Run

cargo run --example multiwebviewto play with it:Ref #2972 #2709 #2076