Skip to content
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

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

Merged
merged 60 commits into from
Jan 24, 2024

Conversation

lucasfernog
Copy link
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

core/tauri-runtime/src/lib.rs Outdated Show resolved Hide resolved
core/tauri/src/menu/plugin.rs Outdated Show resolved Hide resolved
core/tauri/src/menu/plugin.rs Outdated Show resolved Hide resolved
@lucasfernog lucasfernog merged commit c77b403 into dev Jan 24, 2024
35 of 36 checks passed
@lucasfernog lucasfernog deleted the feat/multiwebview branch January 24, 2024 14:05
@thewh1teagle
Copy link
Contributor

Opened related issue
#8676

@jkinggg
Copy link

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?

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.

10 participants