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

A small note on close event listeners #228

Open
anudeepreddy opened this issue Nov 17, 2022 · 0 comments
Open

A small note on close event listeners #228

anudeepreddy opened this issue Nov 17, 2022 · 0 comments

Comments

@anudeepreddy
Copy link

Currently all the event listeners that handle close are set to be handled at bubbling phase.

if (state.visible) {
      window.addEventListener('keydown', handleKeyboard);

      for (const ev of hideOnEvents) window.addEventListener(ev, hide);
    }

Will there be any unintended consequences if we take the approach mentioned below?
Change all the events to be handled during capture phase, this offers us the following advantages:

  • scroll: the behavior gets inline with the browser's default context menu
    • works with any scroll action (even when there is no scroll bar). This should fix How to close contex menu when scrolling #161.
    • works even when scroll happens anywhere on the screen. Consider a two column layout where the right one has the context menu and the left one has a scroll. The menu will close when the scroll happens in the left column(browser's default context menu works like this).
  • other events: there might be few elements on the screen which might do stopPropagation and prevent the context menu from closing. capturing the event fixes this issue.

Also adding a mousedown event would be helpful in cases where we have elements that are draggable.

I would be happy to work on this if you are okay with this.

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

No branches or pull requests

1 participant