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

USWDS - Tooltip: Add escape to behaviors #5920

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mahoneycm
Copy link
Contributor

@mahoneycm mahoneycm commented May 10, 2024

Summary

Moves new tooltipEscape function to behaviors map

Related issue

#5901

Related pull requests

Continuation of #5909

Preview link

Tooltip preview →

Problem statement

Summarize the problem this PR solves in a clear and concise statement.

Solution

Provide a summary of the solution this PR offers.

Major changes

For complex PRs, create a list of the significant updates made.

Testing and review

Share recommended methods for reviewing this change.

@mahoneycm mahoneycm changed the base branch from develop to al-tooltip-escape May 10, 2024 14:29
Comment on lines +396 to +398
keydown: {
[BODY]: keymap({ Escape: handleEscape})
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for making this work with our more standard code patterns, @mahoneycm.

One thing I noticed with this method is that the page registers escape presses even when the tooltip is inactive. What I liked about manually adding and removing the eventlistener on mouse over/out or focus in/out is that the window only would register the key presses when the tooltip is active. I feel like this would limit unintended interaction with other components that also rely on the escape keypress. Curious what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great point! To be honest I'm not too familiar with the benefit/loss of having a persistent listener but I understand the principle of only listening for the keypress while the tooltip is active!

I considered having an early return in handleEscape if there were no active tooltips but that doesn't change the fact that the listener will be there the entire time.

Happy to move forward with the other solution if we feel like there is additional value there!

Base automatically changed from al-tooltip-escape to develop May 22, 2024 22:16
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.

None yet

2 participants