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(picker): added a custom class to make :focus-visible styles consistent across all browsers #4724

Merged
merged 6 commits into from
Sep 16, 2024

Conversation

TarunAdobe
Copy link
Contributor

@TarunAdobe TarunAdobe commented Sep 5, 2024

Description

Added a custom remove-focus-ring-safari-hack class that gets applied when the picker (that is opened using a mouse click) closes after making a selection in a mobile environment using webkit.

This class unsets the focus-ring properties that we apply for the :focus-visible pseudo class.

This is needed so that we don't get focus-ring styles on making a selection in an action-menu in a IOS device.

Related issue(s)

Motivation and context

Blue Focus Ring should not appear on the action-menu and picker on opening and closing in IOS mobile devices.

How has this been tested?

  • I opened storybook and manually tested the following scenarios.

On IOS mobile devices

Test 1 -

  • Click on the action-menu and make a selection.
  • There is no focus-ring styles on the action-menu anymore.

Test 2 -

  • Click on the action-menu and click outside to close it.
  • There is no focus-ring styles on the action-menu anymore.

Test 3 -

  • Click on the action-menu and click outside to close it.
  • There is no focus-ring styles on the action-menu anymore.
  • Use tab and then shift-tab to focus back on the action using the keyboard.
  • The focus-ring appears on the action-menu as expected.

On All Desktop Devices

Test 1 -

  • Click on the action-menu and make a selection.
  • There is no focus-ring styles on the action-menu.

Test 2 -

  • Tab into the action-menu.
  • The focus-ring is shown as expected.
  • Use keyboard navigation to make a selection after opening the action menu using "enter" key.
  • The focus-ring is shown as expected.

Screenshots (if appropriate)

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.

@TarunAdobe TarunAdobe requested a review from a team as a code owner September 5, 2024 06:02
Copy link

github-actions bot commented Sep 5, 2024

Branch preview

Visual regression test results

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

Copy link

github-actions bot commented Sep 5, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.99 0.99 0.99
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 225.889 kB 214.535 kB 🏆 214.621 kB
Scripts 55.317 kB 49.936 kB 🏆 50.032 kB
Stylesheet 34.48 kB 30.171 kB 30.166 kB 🏆
Document 6.189 kB 5.449 kB 5.433 kB 🏆
Font 126.957 kB 126.632 kB 🏆 126.641 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

@coveralls
Copy link
Collaborator

coveralls commented Sep 5, 2024

Pull Request Test Coverage Report for Build 10844986518

Details

  • 14 of 21 (66.67%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.03%) to 98.18%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/picker/src/MobileController.ts 14 21 66.67%
Totals Coverage Status
Change from base Build 10808456663: -0.03%
Covered Lines: 32522
Relevant Lines: 32960

💛 - Coveralls

@TarunAdobe TarunAdobe force-pushed the fix/blue-ring-action-menu branch from 7f09c89 to 8c1dfeb Compare September 5, 2024 06:20
Copy link

github-actions bot commented Sep 5, 2024

Tachometer results

Chrome

action-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 501 kB 51.64ms - 52.56ms - faster ✔
3% - 6%
1.60ms - 3.17ms
branch 477 kB 53.84ms - 55.13ms slower ❌
3% - 6%
1.60ms - 3.17ms
-

action-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 529 kB 70.88ms - 75.53ms - unsure 🔍
-11% - +1%
-8.78ms - +0.60ms
branch 506 kB 73.22ms - 81.37ms unsure 🔍
-1% - +12%
-0.60ms - +8.78ms
-

action-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 552 kB 48.88ms - 50.43ms - faster ✔
3% - 7%
1.59ms - 3.46ms
branch 529 kB 51.66ms - 52.70ms slower ❌
3% - 7%
1.59ms - 3.46ms
-

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 669 kB 141.10ms - 143.96ms - faster ✔
4% - 7%
6.62ms - 10.72ms
branch 648 kB 149.73ms - 152.66ms slower ❌
5% - 8%
6.62ms - 10.72ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 623 kB 67.43ms - 69.03ms - faster ✔
6% - 8%
4.04ms - 6.09ms
branch 605 kB 72.66ms - 73.93ms slower ❌
6% - 9%
4.04ms - 6.09ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 622 kB 65.45ms - 66.56ms - faster ✔
7% - 9%
5.34ms - 6.88ms
branch 604 kB 71.58ms - 72.65ms slower ❌
8% - 10%
5.34ms - 6.88ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 813 kB 1879.71ms - 1882.33ms - unsure 🔍
+0% - +0%
+4.69ms - +8.31ms
branch 791 kB 1873.28ms - 1875.76ms unsure 🔍
-0% - -0%
-8.31ms - -4.69ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 812 kB 1874.84ms - 1877.68ms - unsure 🔍
-0% - -0%
-4.67ms - -0.93ms
branch 789 kB 1877.83ms - 1880.29ms unsure 🔍
+0% - +0%
+0.93ms - +4.67ms
-

breadcrumbs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 686 kB 492.21ms - 496.51ms - faster ✔
2% - 3%
8.67ms - 16.92ms
branch 664 kB 503.63ms - 510.67ms slower ❌
2% - 3%
8.67ms - 16.92ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 730 kB 37.75ms - 38.69ms - faster ✔
1% - 3%
0.30ms - 1.37ms
branch 705 kB 38.81ms - 39.30ms slower ❌
1% - 4%
0.30ms - 1.37ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 730 kB 398.25ms - 403.56ms - faster ✔
3% - 4%
10.44ms - 18.49ms
branch 706 kB 412.35ms - 418.39ms slower ❌
3% - 5%
10.44ms - 18.49ms
-

contextual-help permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 657 kB 51.57ms - 53.80ms - faster ✔
4% - 10%
2.40ms - 5.57ms
branch 633 kB 55.54ms - 57.80ms slower ❌
4% - 11%
2.40ms - 5.57ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 494 kB 217.21ms - 221.73ms - faster ✔
1% - 4%
3.35ms - 8.49ms
branch 471 kB 224.17ms - 226.61ms slower ❌
2% - 4%
3.35ms - 8.49ms
-

overlay permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 711 kB 447.73ms - 452.83ms - faster ✔
0% - 4%
0.40ms - 16.86ms
branch 687 kB 451.08ms - 466.73ms slower ❌
0% - 4%
0.40ms - 16.86ms
-

directive-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 791 kB 22.78ms - 23.78ms - faster ✔
7% - 11%
1.76ms - 2.85ms
branch 766 kB 25.37ms - 25.81ms slower ❌
7% - 12%
1.76ms - 2.85ms
-

element-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 780 kB 357.52ms - 363.32ms - faster ✔
2% - 4%
6.15ms - 13.11ms
branch 755 kB 368.12ms - 371.97ms slower ❌
2% - 4%
6.15ms - 13.11ms
-

lazy-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 577 kB 42.75ms - 43.49ms - faster ✔
7% - 9%
3.12ms - 4.25ms
branch 552 kB 46.38ms - 47.24ms slower ❌
7% - 10%
3.12ms - 4.25ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 536 kB 520.91ms - 530.13ms - faster ✔
2% - 4%
10.47ms - 23.65ms
branch 514 kB 537.87ms - 547.30ms slower ❌
2% - 5%
10.47ms - 23.65ms
-

popover permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 396 kB 11.44ms - 11.64ms - faster ✔
2% - 5%
0.21ms - 0.63ms
branch 374 kB 11.77ms - 12.15ms slower ❌
2% - 6%
0.21ms - 0.63ms
-

split-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 747 kB 1868.39ms - 1872.38ms - unsure 🔍
-0% - +0%
-2.93ms - +2.80ms
branch 724 kB 1868.40ms - 1872.51ms unsure 🔍
-0% - +0%
-2.80ms - +2.93ms
-

tooltip permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 590 kB 34.97ms - 35.83ms - faster ✔
3% - 6%
1.02ms - 2.19ms
branch 542 kB 36.60ms - 37.40ms slower ❌
3% - 6%
1.02ms - 2.19ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 548 kB 23.45ms - 23.94ms - faster ✔
7% - 10%
1.71ms - 2.59ms
branch 525 kB 25.48ms - 26.21ms slower ❌
7% - 11%
1.71ms - 2.59ms
-

test-element permalink

Version Bytes Avg Time vs remote vs branch
npm latest 672 kB 53.67ms - 54.67ms - faster ✔
5% - 7%
2.60ms - 4.09ms
branch 648 kB 56.96ms - 58.07ms slower ❌
5% - 8%
2.60ms - 4.09ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 648 kB 43.08ms - 43.91ms - faster ✔
6% - 8%
2.61ms - 3.83ms
branch 624 kB 46.26ms - 47.16ms slower ❌
6% - 9%
2.61ms - 3.83ms
-

truncated permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 544 kB 59.31ms - 63.86ms - unsure 🔍
-9% - +0%
-6.18ms - +0.07ms
branch 520 kB 62.49ms - 66.78ms unsure 🔍
-0% - +10%
-0.07ms - +6.18ms
-
Firefox

action-bar permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 501 kB 109.90ms - 116.58ms - unsure 🔍
-5% - +2%
-6.27ms - +1.79ms
branch 477 kB 113.22ms - 117.74ms unsure 🔍
-2% - +6%
-1.79ms - +6.27ms
-

action-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 529 kB 143.47ms - 149.69ms - faster ✔
2% - 9%
3.44ms - 14.12ms
branch 506 kB 151.03ms - 159.69ms slower ❌
2% - 10%
3.44ms - 14.12ms
-

action-group permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 552 kB 110.26ms - 116.38ms - faster ✔
1% - 8%
1.46ms - 9.22ms
branch 529 kB 116.27ms - 121.05ms slower ❌
1% - 8%
1.46ms - 9.22ms
-

action-menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 669 kB 272.34ms - 276.90ms - faster ✔
11% - 13%
32.78ms - 39.10ms
branch 648 kB 308.37ms - 312.75ms slower ❌
12% - 14%
32.78ms - 39.10ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 623 kB 131.81ms - 134.79ms - unsure 🔍
-2% - +1%
-2.28ms - +1.52ms
branch 605 kB 132.50ms - 134.86ms unsure 🔍
-1% - +2%
-1.52ms - +2.28ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 622 kB 136.01ms - 143.15ms - unsure 🔍
-0% - +6%
-0.05ms - +8.65ms
branch 604 kB 132.80ms - 137.76ms unsure 🔍
-6% - -0%
-8.65ms - +0.05ms
-

test-open-close-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 813 kB 1900.68ms - 1906.48ms - slower ❌
1% - 1%
11.72ms - 19.96ms
branch 791 kB 1884.82ms - 1890.66ms faster ✔
1% - 1%
11.72ms - 19.96ms
-

test-open-close permalink

Version Bytes Avg Time vs remote vs branch
npm latest 812 kB 1892.35ms - 1897.85ms - unsure 🔍
-0% - +0%
-5.80ms - +1.48ms
branch 789 kB 1894.88ms - 1899.64ms unsure 🔍
-0% - +0%
-1.48ms - +5.80ms
-

breadcrumbs permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 686 kB 796.09ms - 805.83ms - faster ✔
2% - 4%
16.60ms - 35.04ms
branch 664 kB 818.94ms - 834.62ms slower ❌
2% - 4%
16.60ms - 35.04ms
-

combobox permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 730 kB 61.44ms - 63.76ms - unsure 🔍
-2% - +1%
-1.52ms - +0.88ms
branch 705 kB 62.61ms - 63.23ms unsure 🔍
-1% - +2%
-0.88ms - +1.52ms
-

light-dom-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 730 kB 747.29ms - 761.11ms - slower ❌
2% - 5%
12.48ms - 36.16ms
branch 706 kB 720.27ms - 739.49ms faster ✔
2% - 5%
12.48ms - 36.16ms
-

contextual-help permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 657 kB 107.45ms - 113.11ms - faster ✔
1% - 7%
0.90ms - 8.30ms
branch 633 kB 112.49ms - 117.27ms slower ❌
1% - 8%
0.90ms - 8.30ms
-

menu permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 494 kB 424.05ms - 434.31ms - faster ✔
1% - 4%
4.64ms - 19.92ms
branch 471 kB 435.80ms - 447.12ms slower ❌
1% - 5%
4.64ms - 19.92ms
-

overlay permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 787 kB 627.92ms - 641.16ms - slower ❌
1% - 4%
8.82ms - 24.34ms
branch 762 kB 613.90ms - 622.02ms faster ✔
1% - 4%
8.82ms - 24.34ms
-

directive-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 791 kB 45.63ms - 46.33ms - faster ✔
4% - 7%
2.02ms - 3.22ms
branch 766 kB 48.12ms - 49.08ms slower ❌
4% - 7%
2.02ms - 3.22ms
-

element-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 780 kB 649.80ms - 658.40ms - slower ❌
4% - 5%
22.65ms - 33.31ms
branch 755 kB 622.98ms - 629.26ms faster ✔
3% - 5%
22.65ms - 33.31ms
-

lazy-test permalink

Version Bytes Avg Time vs remote vs branch
npm latest 577 kB 95.70ms - 103.82ms - slower ❌
4% - 13%
3.35ms - 11.57ms
branch 552 kB 91.67ms - 92.93ms faster ✔
4% - 11%
3.35ms - 11.57ms
-

picker permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 536 kB 975.97ms - 999.43ms - faster ✔
4% - 6%
39.44ms - 65.40ms
branch 514 kB 1034.55ms - 1045.69ms slower ❌
4% - 7%
39.44ms - 65.40ms
-

popover permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 396 kB 27.53ms - 30.83ms - unsure 🔍
-15% - +0%
-4.84ms - +0.16ms
branch 374 kB 29.64ms - 33.40ms unsure 🔍
-1% - +17%
-0.16ms - +4.84ms
-

split-button permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 747 kB 1874.34ms - 1877.90ms - unsure 🔍
-0% - -0%
-8.14ms - -2.46ms
branch 724 kB 1879.21ms - 1883.63ms unsure 🔍
+0% - +0%
+2.46ms - +8.14ms
-

tooltip permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 672 kB 78.83ms - 83.05ms - slower ❌
7% - 13%
5.29ms - 9.79ms
branch 648 kB 72.60ms - 74.20ms faster ✔
7% - 12%
5.29ms - 9.79ms
-

test-directive permalink

Version Bytes Avg Time vs remote vs branch
npm latest 548 kB 46.65ms - 48.83ms - faster ✔
5% - 14%
2.70ms - 7.62ms
branch 525 kB 50.70ms - 55.10ms slower ❌
6% - 16%
2.70ms - 7.62ms
-

test-element permalink

Version Bytes Avg Time vs remote vs branch
npm latest 672 kB 130.96ms - 138.88ms - slower ❌
6% - 13%
7.05ms - 15.91ms
branch 648 kB 121.47ms - 125.41ms faster ✔
5% - 12%
7.05ms - 15.91ms
-

test-lazy permalink

Version Bytes Avg Time vs remote vs branch
npm latest 648 kB 89.50ms - 93.54ms - faster ✔
9% - 15%
8.91ms - 15.33ms
branch 624 kB 101.15ms - 106.13ms slower ❌
10% - 17%
8.91ms - 15.33ms
-

truncated permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 544 kB 105.77ms - 112.39ms - unsure 🔍
-6% - +2%
-6.53ms - +2.25ms
branch 520 kB 108.34ms - 114.10ms unsure 🔍
-2% - +6%
-2.25ms - +6.53ms
-

// if the focus comes from a closing the menu, we need to make sure to
// unset the :focus-visible state to avoid the focus ring on safari mobile
if (isWebKit() && !this.open) {
this.target.blur();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure that .blur() is the desired approach here? From my understanding, using .blur() will remove focus from the element entirely, but our intention seems to be to keep the element focused while only removing the visual indication (the focus ring). Or how does it work in the other browsers?
Can we check where the focus goes with this implementation? Does it impact keyboard navigation?

@TarunAdobe TarunAdobe changed the title fix(picker): do not force focus visible on click in safari fix(picker): added a custom class to make :focus-visible styles consistent across all browsers Sep 11, 2024
@TarunAdobe TarunAdobe force-pushed the fix/blue-ring-action-menu branch from 8ac0d19 to 676b986 Compare September 12, 2024 04:08
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.

This solution is actually ingenious! 😄
Do you think we could try and cover this with a simple test? I believe we can mock the isWebKit and check the computed style of the ::after pseudo element. Let me know if you want to sync on this 👍

.stylelintrc.json Outdated Show resolved Hide resolved
packages/action-button/src/action-button.css Show resolved Hide resolved
packages/picker/src/MobileController.ts Outdated Show resolved Hide resolved
Rajdeepc

This comment was marked as outdated.

@Rajdeepc Rajdeepc dismissed their stale review September 12, 2024 08:12

Missed on the lint change that doesnt need to be addressed here in this PR

@Rajdeepc
Copy link
Contributor

This solution is actually ingenious! 😄 Do you think we could try and cover this with a simple test? I believe we can mock the isWebKit and check the computed style of the ::after pseudo element. Let me know if you want to sync on this 👍

Something on this front.

const isWebKitMacOS = isWebKit() && detectOS() === 'Mac OS';

@TarunAdobe
Copy link
Contributor Author

Note: I have to add tests to this and also make sure that it works for picker and other related components (if any)

Copy link
Contributor

@Rajdeepc Rajdeepc left a comment

Choose a reason for hiding this comment

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

Looks good!

@TarunAdobe TarunAdobe merged commit d667d08 into main Sep 16, 2024
60 of 61 checks passed
@TarunAdobe TarunAdobe deleted the fix/blue-ring-action-menu branch September 16, 2024 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: [Ipad] Blue focus ring appear on the button after opening/closing ActionMenu component.
4 participants