8000 Every tooltip adds a keydown event listener to the window · Issue #1268 · melt-ui/melt-ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Every tooltip adds a keydown event listener to the window #1268

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

Closed
WindySpoon opened this issue Sep 24, 2024 · 3 comments
Closed

Every tooltip adds a keydown event listener to the window #1268

WindySpoon opened this issue Sep 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@WindySpoon
Copy link

Describe the bug

image

Every tooltip adds a keydown event listener to the window.
I tested this on both Firefox and Chrome and its the same problem.
Removing the tooltips also removes these listeners.

Reproduction

  1. Add the Tooltip component multiple times.
  2. You will notice that a new event listener for keydown is added to the window every time you add a Tooltip.

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (16) x64 AMD Ryzen 7 7730U with Radeon Graphics
    Memory: 7.52 GB / 15.40 GB
  Binaries:
    Node: 20.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.3 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.27 - ~\.bun\bin\bun.EXE
  Browsers: {}
  npmPackages:
    @sveltejs/kit: ^2.0.0 => 2.5.28
    svelte: ^4.2.7 => 4.2.19

Severity

annoyance

@WindySpoon WindySpoon added the bug Something isn't working label Sep 24, 2024
@TGlide
Copy link
Member
TGlide commented Sep 24, 2024

This is intended, whats the issue?

@WindySpoon
Copy link
Author

I would assume that using one event listener and then sending to every tooltip component is out of the question, because of how these components are setup. But my thinking was that so many event listeners all listening to keydown would just use unnecessary resources. I could be overthinking this, and having so many event listeners is fine, but I just wanted to make sure that is the case.

Another option could be attaching the event listener to the parent of the tooltip, for example if the tooltip is attached to a button, then attach the event listener to the button.

@TGlide
Copy link
Member
TGlide commented Sep 25, 2024

A lot of JS frameworks work by delegating events to the document, even Svelte in the new version. I don't think it's an issue :)

Attaching to the button is not feasible for this specific listener, as it detects mouse position to see if we should close the tooltip. We don't close it even if its outside the button, as long as its between the button and the content.

will close this one!

@TGlide TGlide closed this as completed Sep 25, 2024
@TGlide TGlide closed this as not planned Won't fix, can't repro, duplicate, stale Sep 25, 2024
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
0