pkg/lib: fix context menu component popdown #20650
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
f9b0166 changed the popdown behaviour of the context menu.
Before that commit, the previous code was wrong. It was:
but because
event.target.contains
is a function, the comparison was always false and wasOutside would always be true. This meant that any left click would always pop the menu down.The replacement code was:
which at least looks like it does something meaningful. Unfortunately this is also wrong, but in the other direction: this means that the menu will only pop down if it's not contained inside of the item you've clicked on. If you click on a large top-level
We seemed to be happy with the behaviour before the original change, but the code has a purpose: it allows clicking on content of the menu (like on a divider, for example) without dismissing it. Let's try to implement the intended original behaviour: we should dismiss the menu only if the element that we clicked on is outside of the menu:
Fixes #20649