Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(overlay): safari :focus-visible inconsistency when using overlay type modal #4912

Merged
merged 14 commits into from
Jan 27, 2025

Conversation

mizgaionutalexandru
Copy link
Contributor

@mizgaionutalexandru mizgaionutalexandru commented Nov 7, 2024

Description

This PR makes so that the tooltip isn't shown after a click overlay (e.g. popover) is opened in Safari in a type="modal" overlay, to have the same behaviour as in Chrome/Firefox. The inconsistency comes from the different heuristics Webkit uses to apply the focus-visible pseudo-class on elements.

Related issue(s)

Motivation and context

The main motivation is consistency across browsers/engines.

How has this been tested?

These test cases have been tested in Safari as well as other supported browsers (e.g. Chrome).

  • Test case 1

    1. Open the storybook on an overlay with type="modal" and a click and hover effect
    2. Click on the button to open the popover (the 'click' content)
    3. Click outside the popover to close it
    4. Observe that the button does NOT have a focus ring around it and the tooltip does NOT open
  • Test case 2

    1. Open the storybook on an overlay with type="modal" and a click and hover effect
    2. Tab to the button
    3. Observe that the tooltip is opened and the focus ring appears
    4. Press 'Enter' to open the popover (the 'click' content)
    5. Press 'Escape' to close the popover
    6. Observe that the tooltip is opened and the focus ring appears
    7. Repeat with Tab and Shift+Tab
  • Did it pass in Desktop?

  • Did it pass in Mobile?

  • Did it pass in iPad?

Screenshots (if appropriate)

Before the fix:

before.mov

After the fix:

after.mov

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

github-actions bot commented Nov 7, 2024

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

@coveralls
Copy link
Collaborator

coveralls commented Nov 7, 2024

Pull Request Test Coverage Report for Build 12986995120

Details

  • 45 of 50 (90.0%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.02%) to 98.189%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/overlay/src/HoverController.ts 30 35 85.71%
Totals Coverage Status
Change from base Build 12951330367: -0.02%
Covered Lines: 33052
Relevant Lines: 33481

💛 - Coveralls

Copy link

github-actions bot commented Nov 7, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.97 0.97
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 249.656 kB 236.132 kB 🏆 236.536 kB
Scripts 59.829 kB 54.253 kB 🏆 54.469 kB
Stylesheet 53.954 kB 47.346 kB 🏆 47.598 kB
Document 6.235 kB 5.513 kB 5.462 kB 🏆
Font 126.882 kB 126.606 kB 🏆 126.657 kB

Request Count

Category Latest Main Branch
Total 52 52 52
Scripts 41 41 41
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

Copy link

github-actions bot commented Nov 7, 2024

Tachometer results

Currently, no packages are changed by this PR...


// This fails but when manually tested it works in the browser
// in the test it shows that the tooltip is open (overlayTrigger.open === 'hover')
// expect(overlayTrigger.open).to.be.undefined;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would appreciate any feedback/ideas on why would this be flaky, couldn't yet figure out why this would fail if manually tested it works.

Copy link
Contributor

Choose a reason for hiding this comment

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

iinnnteresting

await closed;

// Manually testing this in the browser doesn't fail without the handleKeyup method but it should
// expect(overlayTrigger.open).to.equal('hover');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same thing here as in the previous test.

@mizgaionutalexandru mizgaionutalexandru marked this pull request as ready for review November 7, 2024 13:37
@mizgaionutalexandru mizgaionutalexandru requested a review from a team as a code owner November 7, 2024 13:37
@Rajdeepc
Copy link
Contributor

@mizgaionutalexandru Thanks for doing this! Shaping up well! By any chance were you able to test this in a touch interface?

@mizgaionutalexandru
Copy link
Contributor Author

@mizgaionutalexandru Thanks for doing this! Shaping up well! By any chance were you able to test this in a touch interface?

Yes, I have tested this on mobile and tablet simulators as well as a real iPad device. It seems to work just fine. I don't know why the written tests fail though.

Copy link
Contributor

@TarunAdobe TarunAdobe left a comment

Choose a reason for hiding this comment

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

This needs to be updated so as to make sure the hover tooltip opens in the following case on other browsers too.

  1. Click on the trigger open the popover
  2. press escape
    (expect the hover to be opened again)

@mizgaionutalexandru mizgaionutalexandru force-pushed the imizga/ios-focus-indicator branch from 19f8cee to 6f4fca8 Compare January 13, 2025 14:29
Copy link

changeset-bot bot commented Jan 13, 2025

⚠️ No Changeset found

Latest commit: 8bd89c7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@rubencarvalho
Copy link
Collaborator

If we can just remove that forgotten .only, I am good to merge this! 👍

Copy link
Collaborator

@rubencarvalho rubencarvalho left a comment

Choose a reason for hiding this comment

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

Thank you for this! 😃

Copy link
Contributor

@TarunAdobe TarunAdobe left a comment

Choose a reason for hiding this comment

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

Tests are still failing when run parallel to other ones. They're only passing if we only run those tests separately. We'll have to take another look :(

@TarunAdobe TarunAdobe merged commit 7a5f786 into main Jan 27, 2025
27 checks passed
@TarunAdobe TarunAdobe deleted the imizga/ios-focus-indicator branch January 27, 2025 13:40
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants