This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
Fix bug with keyboard input in click tooltips #18044
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.
Description of the Change
In https://github.com/atom/atom/pull/17651/files, @cacheflow (hi! I think we follow each other on twitter, fancy seeing you here 😄 ) fixed a bug where tooltips were obscuring some of the areas in a user workspace, by making the tooltips disappear on keydown.
Unfortunately, this fix led to some unfortunate side effects. Some tooltips (such as Teletype, and the github atom branch creation menu) need keyboard functionality. These tooltips were closing on keypress, so users couldn't actually enter the input. Also,
window.addEventListener
was being called every time a new tooltip was registered/added to theTooltipManager
, which led to the creation of many additional keyboard listeners. Atom generally follows the event delegation pattern, to avoid unnecessary listeners as it's bad for performance.This fix scopes @cacheflow's original changes to only tooltips that are triggered on hover. The assumption being, hover tooltips are most likely to get in the way. The thinking is, click-triggered tooltips are more likely to be intentionally triggered (and all the input tooltips I'm aware of are click-triggered.) It also attaches/removes the event listeners when a hover tooltip is shown, rather than when the tooltip is registered with the event manager. That's going to cut down on the number of listeners.
Alternate Designs
I'm a little afraid of the event handling code in atom/atom and tbh didn't really consider any alternatives.
Why Should This Be In Core?
It's a bugfix of existing core functionality.
Benefits
Teletype and the github atom branch selector work again.
Possible Drawbacks
The handling for events in Atom is complicated. It's possible that this fix could trigger undesirable behavior. For example, if there are tooltips that are triggered by a click, that are blocking somewhere where a user wants to type, the user will have to dismiss these tooltips with a click.
Verification Process
Applicable Issues
#18041