Skip to content

refactor(core): add support to multiple webviews on a Tauri window#8280

Merged
lucasfernog merged 60 commits intodevfrom
feat/multiwebview
Jan 24, 2024
Merged

refactor(core): add support to multiple webviews on a Tauri window#8280
lucasfernog merged 60 commits intodevfrom
feat/multiwebview

Conversation

@lucasfernog
Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

Currently the Tauri's Window type (both the Rust struct and JS class) are actually a mix of the tao Window and the wry Webview. In order to support multiple webviews on a given window, we actually have to split those types. This PR makes that change so now WindowBuilder and Window only exposes the window APIs, and we added WebviewBuilder and Webview.

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 unstable feature flag. Specially the auto resize thing needs more work and configuration.

Run cargo run --example multiwebview to play with it:
Screenshot 2023-11-21 at 16 57 36

Ref #2972 #2709 #2076

Comment thread core/tauri-runtime/src/lib.rs Outdated
Comment thread core/tauri/src/menu/plugin.rs Outdated
Comment thread core/tauri/src/menu/plugin.rs Outdated
@lucasfernog lucasfernog merged commit c77b403 into dev Jan 24, 2024
@lucasfernog lucasfernog deleted the feat/multiwebview branch January 24, 2024 14:05
@thewh1teagle
Copy link
Copy Markdown
Contributor

Opened related issue
#8676

@jkinggg
Copy link
Copy Markdown

jkinggg commented Apr 23, 2024

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?

@nileshtrivedi
Copy link
Copy Markdown

Is there an example of adding a new child webview to the main window when processing a command?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.