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

next: No cleanup of event listeners in menu component #1070

Closed
Fruup opened this issue Jan 28, 2025 · 0 comments
Closed

next: No cleanup of event listeners in menu component #1070

Fruup opened this issue Jan 28, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Fruup
Copy link

Fruup commented Jan 28, 2025

Describe the bug

This applies to bits-ui@1.0.0-next.78.

When using the dropdown component (or any menu component), event listeners are registered to determine if the user is using a keyboard for navigation. The cleanup logic is faulty, leading to dangling event listeners (and a lot of them). On large sites, this soon leads to performance issues.


This:

executeCallbacks(callbacksToDispose);

should be

executeCallbacks(...callbacksToDispose)();

(Frankly, the definition of executeCallbacks is not very clear or type-safe.)


Will open a PR with a fix :)

Reproduction

https://stackblitz.com/edit/bits-ui-missing-listener-cleanup-repro?file=src%2Froutes%2F%2Blayout.svelte

Logs

System Info

System:
    OS: macOS 15.1.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 100.13 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.15.3 - ~/Library/pnpm/pnpm
    bun: 1.2.1 - ~/.bun/bin/bun
  Browsers:
    Chrome: 132.0.6834.111
    Safari: 18.1.1
  npmPackages:
    @sveltejs/kit: ^2.0.0 => 2.16.1 
    bits-ui: 1.0.0-next.78 => 1.0.0-next.78 
    svelte: ^5.0.0 => 5.19.4

Severity

annoyance

@huntabyte huntabyte added the bug Something isn't working label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants