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

fix: dangling event listeners on menu #1071

Merged
merged 5 commits into from
Jan 29, 2025

Conversation

Fruup
Copy link

@Fruup Fruup commented Jan 28, 2025

Fixes #1070


I took the opportunity to optimize the determination of the user's input mode (pointer or keyboard). Now, only three event listeners are registered and can be shared between multiple components.

I took inspiration from @huntabyte's branch fix/focus-scoping where a class IsUsingKeyboard is already implemented.


Many thanks to @chbert with whom I troubleshot this issue extensively :)

Copy link

changeset-bot bot commented Jan 28, 2025

🦋 Changeset detected

Latest commit: 8dc8bbd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
bits-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Fruup Fruup marked this pull request as ready for review January 28, 2025 21:32
Copy link
Contributor

github-actions bot commented Jan 29, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
bits-ui ✅ Ready (View Log) Visit Preview 8dc8bbd

callbacksToDispose.push(disposeKeydown);

return () => {
executeCallbacks(callbacksToDispose);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on this one :)

@huntabyte
Copy link
Owner

Very nice work. Tbh, I hadn't even though of the idea of a global IsUsingKeyboard state that could be shared/deduped between components. Really appreciate this PR!

@Fruup
Copy link
Author

Fruup commented Jan 29, 2025

Not sure about this, but should I add a "minor" changeset because the new IsUsingKeyboard utility is exposed?

@huntabyte
Copy link
Owner

We just do everything "patch" while we're in pre-release mode so it's one flat changelog when we merge/release 1.0. Future majors will have appropriate patch/minor/major(breaking) changes annotated.

I don't mind exporting IsUsingKeyboard, so if we are we should add a documentation page for it alongside the other utils we export.

I can do that once I'm done with work later unless you want to!

Thanks again for this!

@Fruup
Copy link
Author

Fruup commented Jan 29, 2025

Feel free to take it from here :)
My pleasure!

@huntabyte huntabyte merged commit 48655fc into huntabyte:next Jan 29, 2025
5 checks passed
@Fruup Fruup deleted the fix/is-using-keyboard branch January 30, 2025 08:05
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