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

fix(tooltip): prevent hide when focus is within tooltip #1811

Merged
merged 9 commits into from
Oct 30, 2024

Conversation

dancormier
Copy link
Contributor

@dancormier dancormier commented Sep 4, 2024

https://stackoverflow.atlassian.net/browse/STACKS-667


This PR prevents the tooltip from hiding when focus is moved to an element within the tooltip.

To test

  • Go to the "Rich tooltips" section of the popover docs page
  • Tab to the button in this section
  • Once the tooltip shows, tab to the link within
    • The tooltip should remain visible
  • Tab so the focus is no longer on the triggering button or within the tooltip
    • The tooltip should hide

TODO

  • Implement test

@dancormier dancormier added the bug A reproducible problem with the Stacks code label Sep 4, 2024
@dancormier dancormier requested review from qheaden-stack and a team September 4, 2024 21:38
Copy link

netlify bot commented Sep 4, 2024

Deploy Preview for stacks ready!

Name Link
🔨 Latest commit 6b11d3c
🔍 Latest deploy log https://app.netlify.com/sites/stacks/deploys/66d8d369b80686000810d5e8
😎 Deploy Preview https://deploy-preview-1811--stacks.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dancormier dancormier marked this pull request as ready for review October 29, 2024 22:49
Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for stacks failed. Why did it fail? →

Name Link
🔨 Latest commit 2a6c2f5
🔍 Latest deploy log https://app.netlify.com/sites/stacks/deploys/6721664aa919b200085a0797

Copy link

netlify bot commented Oct 29, 2024

Deploy Preview for stacks failed. Why did it fail? →

Name Link
🔨 Latest commit 54bc2f4
🔍 Latest deploy log https://app.netlify.com/sites/stacks/deploys/67226c3ac5f971000720332a

@giamir
Copy link
Contributor

giamir commented Oct 30, 2024

@dancormier I took the liberty to swap the sleep functions in the tests with waitFor and waitForElementToBeRemoved since they are reducing significantly the likeness of test flakiness. We should try to stay away from sleep functions as much as possible.
fdb7870

@giamir
Copy link
Contributor

giamir commented Oct 30, 2024

@dancormier Tangential question, I noticed that we recommend to add a aria-hidden="true" in our markup examples but then we don't have any js code in our stimulus controllers that dynamically change that value when the tooltip is displayed/hidden. Should we log a bug?

@dancormier
Copy link
Contributor Author

dancormier commented Oct 30, 2024

Thank you for the review @giamir!

@dancormier I took the liberty to swap the sleep functions in the tests with waitFor and waitForElementToBeRemoved since they are reducing significantly the likeness of test flakiness. We should try to stay away from sleep functions as much as possible. fdb7870

Thank you for this! I entirely forgot about waitFor. I think I was in "how do I get this test to work how I'd expect" mode and never got to "how to make this test work and be as stable as possible".

@dancormier Tangential question, I noticed that we recommend to add a aria-hidden="true" in our markup examples but then we don't have any js code in our stimulus controllers that dynamically change that value when the tooltip is displayed/hidden. Should we log a bug?

Yeah, I think so. I'll go ahead and add a ticket.

Tangentially, it seems like the popover broadly shouldn't include the aria-hidden attribute since we hide it with display: none. See MDN:

aria-hidden="true" should not be added when:

@dancormier dancormier merged commit 45f288b into develop Oct 30, 2024
7 of 11 checks passed
@dancormier dancormier deleted the dcormier/fix-tooltip-focus-within-hide branch October 30, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A reproducible problem with the Stacks code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants