Skip to content

feat(example): rework menu examples#15684

Merged
Legend-Master merged 52 commits into
devfrom
menu-example-rework
Jul 15, 2026
Merged

feat(example): rework menu examples#15684
Legend-Master merged 52 commits into
devfrom
menu-example-rework

Conversation

@Legend-Master

@Legend-Master Legend-Master commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Depends on #15675

The primary reason for building this is to understand where our docs are lacking and which part of the APIs are not ergonomic enough.

I feel like the ownerships of menus are quite confusing, especially from the JavaScript side. The menus are reference counted that means if you have:

  • Menu
    • Item 1
    • Item 2

when you close Menu, Item 1 and Item 2 are also released, but if you somehow got a reference to one of them left, either it's shared to another menu, or you forget the one you get from a Menu.get, you have a leak.

This is something we should definitely improve the docs on


preview of the change:

video.mp4

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through 56dcc2a

There are 14 changes which include tauri with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri-bundler with minor, tauri-utils with minor, tauri-build with minor, tauri-macos-sign with minor, tauri-runtime-wry with minor, tauri-runtime with minor, tauri-codegen with minor, tauri-macros with minor, tauri-plugin with minor, tauri-driver with minor, @tauri-apps/api with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.11.1 2.12.0
tauri-utils 2.9.3 2.10.0
tauri-macos-sign 2.3.4 2.4.0
tauri-bundler 2.9.4 2.10.0
tauri-runtime 2.11.3 2.12.0
tauri-runtime-wry 2.11.4 2.12.0
tauri-codegen 2.6.3 2.7.0
tauri-macros 2.6.3 2.7.0
tauri-plugin 2.6.3 2.7.0
tauri-build 2.6.3 2.7.0
tauri 2.11.5 2.12.0
@tauri-apps/cli 2.11.4 2.12.0
tauri-cli 2.11.4 2.12.0
tauri-driver 2.0.6 2.1.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master

Legend-Master commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Svelte seems to insert comments to the DOM as anchors that simply can't work well with SortableJS...

Edit: did a workaround in d6b562d to always re-create the menus after sorting (referencing sveltejs/svelte#11826 in case someone else stumbles onto this as well) (I still want to stick with SortableJS since it is the best working drag and drop library I have tried so far)

@Legend-Master

Legend-Master commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

I'm still seeing constant memory increases when I spam re-creating the menus, even with the changes from #15679 applied 🤔

From some testing, the handles should be properly freed as well as the resources in the resource table 🤔

The code I used to test

const sleep = (ms: number) =>
  new Promise((resolve) => setTimeout(resolve, ms))

const items = [await MenuItem.new({ text: 'test' })]

for (let index = 0; index < 10_000; index++) {
  const menu = await Submenu.new({
    text: 'app',
    items
  })
  await menu.close()
  await sleep(10)
}

for (const item of items) {
  await item.close()
}

the rust equivalent doesn't reproduce the leak

let item = MenuItemBuilder::new("test").build(&app)?;
for _ in 0..1_000_000 {
  SubmenuBuilder::new(&app, "submenu").item(&item).build()?;
}

@Legend-Master Legend-Master marked this pull request as ready for review July 15, 2026 02:41
@Legend-Master Legend-Master requested a review from a team as a code owner July 15, 2026 02:41
@Legend-Master

Copy link
Copy Markdown
Contributor Author

Anyways, we can do that later, the rework itself is ready and should not leak when we fix the underlying issues.

@FabianLars

Copy link
Copy Markdown
Member

The styling is off in dark mode:
grafik

Just looks like plain text to me and took me a second to realize those are elements i can drag

@Legend-Master

Copy link
Copy Markdown
Contributor Author

It's even weirder from my side 😂

image

I'm so used to the css variable just take care of these but I guess I was the wrong ones 🤦‍♂️

@Legend-Master

Copy link
Copy Markdown
Contributor Author

@FabianLars I am so not used to tailwind, am I supposed to add in CSS variables like we normally do or just spam dark:* like we did right now?

@Legend-Master

Legend-Master commented Jul 15, 2026

Copy link
Copy Markdown
Contributor Author

Spammed a bunch of dark:* for now... I thought sematic color names like accent and neutral would have the dark variant set automatically.

image

@FabianLars

Copy link
Copy Markdown
Member

idk either 😂

@Legend-Master Legend-Master merged commit 42ae2d8 into dev Jul 15, 2026
31 checks passed
@Legend-Master Legend-Master deleted the menu-example-rework branch July 15, 2026 10:23
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.

2 participants