-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix(checkbox,radio,toggle): add missing keyboard focus indicators #31295
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
Open
ShaneK
wants to merge
19
commits into
main
Choose a base branch
from
FW-7585-FW-7586
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+797
−149
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
33e40af
fix(checkbox,radio): show keyboard focus indicator, including in mult…
ShaneK 81736bf
fix(toggle): show keyboard focus indicator via focusable track ring
ShaneK a135348
fix(checkbox,radio,toggle): hide native focus ring on focused controls
ShaneK 5953965
test(checkbox,toggle): capture focus indicator via real keyboard focu…
ShaneK 1568d4a
chore(test): trying to minimize screenshot width
ShaneK 409a0ba
chore(): add updated snapshots
Ionitron 6a3c199
Bdocs(checkbox,radio): add multi-input item focus demo to item test p…
ShaneK 084902b
Merge branch 'FW-7585-FW-7586' of github.com:ionic-team/ionic-framewo…
ShaneK a105ea7
test(checkbox,radio,toggle): add checked/md focus and multi-input ite…
ShaneK c00892d
chore(lint): fixing lint
ShaneK fc10735
chore(): add updated snapshots
Ionitron 1c38112
Merge branch 'FW-7585-FW-7586' of github.com:ionic-team/ionic-framewo…
ShaneK 910cddb
test(checkbox,radio): add multi-input item focus screenshots and fix …
ShaneK edcfb72
chore(): add updated snapshots
Ionitron f758350
Merge branch 'main' of github.com:ionic-team/ionic-framework into FW-…
ShaneK 3dfbf81
Merge remote-tracking branch 'origin/FW-7585-FW-7586' into FW-7585-FW…
ShaneK 0c4b6a1
test(checkbox,radio): move in-item focus tests to item test dir
ShaneK 9c4786a
refactor(checkbox,radio): dedupe focus styles and item input observer
ShaneK 48c5474
refactor(checkbox,radio,toggle): dedupe focus styles into base scss
ShaneK File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| @import "../../themes/ionic.globals"; | ||
|
|
||
| /// @prop - Top margin of checkbox's label when in an item | ||
| $checkbox-item-label-margin-top: 10px; | ||
|
|
||
| /// @prop - Bottom margin of checkbox's label when in an item | ||
| $checkbox-item-label-margin-bottom: 10px; | ||
| $checkbox-item-label-margin-bottom: 10px; | ||
|
|
||
| /// @prop - Background color of focus indicator for checkbox when focused | ||
| $checkbox-background-color-focused: ion-color(primary, tint); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,7 +47,7 @@ configs().forEach(({ title, screenshot, config }) => { | |||||||||||||||
| /** | ||||||||||||||||
| * This behavior does not vary across modes/directions | ||||||||||||||||
| */ | ||||||||||||||||
| configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||||||||||||||||
| configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => { | ||||||||||||||||
| test.describe(title('checkbox: ionChange'), () => { | ||||||||||||||||
| test('should fire ionChange when interacting with checkbox', async ({ page }) => { | ||||||||||||||||
| await page.setContent( | ||||||||||||||||
|
|
@@ -138,48 +138,6 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c | |||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| test.describe(title('checkbox: ionFocus'), () => { | ||||||||||||||||
|
brandyscarney marked this conversation as resolved.
|
||||||||||||||||
| test('should not have visual regressions', async ({ page, pageUtils }) => { | ||||||||||||||||
| await page.setContent( | ||||||||||||||||
| ` | ||||||||||||||||
| <style> | ||||||||||||||||
| #container { | ||||||||||||||||
| display: inline-block; | ||||||||||||||||
| padding: 10px; | ||||||||||||||||
| } | ||||||||||||||||
| </style> | ||||||||||||||||
|
|
||||||||||||||||
| <div id="container"> | ||||||||||||||||
| <ion-checkbox>Unchecked</ion-checkbox> | ||||||||||||||||
| </div> | ||||||||||||||||
| `, | ||||||||||||||||
| config | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| await pageUtils.pressKeys('Tab'); | ||||||||||||||||
|
|
||||||||||||||||
| const container = page.locator('#container'); | ||||||||||||||||
|
|
||||||||||||||||
| await expect(container).toHaveScreenshot(screenshot(`checkbox-focus`)); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| test('should not have visual regressions when interacting with checkbox in item', async ({ page, pageUtils }) => { | ||||||||||||||||
| await page.setContent( | ||||||||||||||||
| ` | ||||||||||||||||
| <ion-item class="ion-focused"> | ||||||||||||||||
| <ion-checkbox>Unchecked</ion-checkbox> | ||||||||||||||||
| </ion-item> | ||||||||||||||||
| `, | ||||||||||||||||
| config | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| // Test focus with keyboard navigation | ||||||||||||||||
| await pageUtils.pressKeys('Tab'); | ||||||||||||||||
|
|
||||||||||||||||
| const item = page.locator('ion-item'); | ||||||||||||||||
|
|
||||||||||||||||
| await expect(item).toHaveScreenshot(screenshot(`checkbox-in-item-focus`)); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| test('should fire ionFocus when checkbox is focused', async ({ page, pageUtils }) => { | ||||||||||||||||
| await page.setContent( | ||||||||||||||||
| ` | ||||||||||||||||
|
|
@@ -328,3 +286,80 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, screenshot, c | |||||||||||||||
| }); | ||||||||||||||||
| }); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * This behavior does not vary across directions | ||||||||||||||||
| */ | ||||||||||||||||
|
Comment on lines
+290
to
+292
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a nit for consistency
Suggested change
|
||||||||||||||||
| configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { | ||||||||||||||||
| test.describe(title('checkbox: focus visual'), () => { | ||||||||||||||||
| test('should render focus indicator when unchecked', async ({ page, pageUtils }) => { | ||||||||||||||||
| // `ion-app` is required so `startFocusVisible` runs and applies the | ||||||||||||||||
| // `ion-focused` class on keyboard focus, which drives the focus indicator. | ||||||||||||||||
| await page.setContent( | ||||||||||||||||
| ` | ||||||||||||||||
| <style> | ||||||||||||||||
| #container { | ||||||||||||||||
| width: fit-content; | ||||||||||||||||
| padding: 10px; | ||||||||||||||||
| } | ||||||||||||||||
| </style> | ||||||||||||||||
|
|
||||||||||||||||
| <ion-app> | ||||||||||||||||
| <div id="container"> | ||||||||||||||||
| <ion-checkbox>Unchecked</ion-checkbox> | ||||||||||||||||
| </div> | ||||||||||||||||
| </ion-app> | ||||||||||||||||
| `, | ||||||||||||||||
| config | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| const checkbox = page.locator('ion-checkbox'); | ||||||||||||||||
|
|
||||||||||||||||
| // The focus listeners attach asynchronously, so the first Tab can miss | ||||||||||||||||
| // them. Retry until `ion-focused` sticks before taking the snapshot. | ||||||||||||||||
| await expect(async () => { | ||||||||||||||||
| await page.evaluate(() => (document.activeElement as HTMLElement | null)?.blur()); | ||||||||||||||||
| await pageUtils.pressKeys('Tab'); | ||||||||||||||||
| await expect(checkbox).toHaveClass(/ion-focused/, { timeout: 250 }); | ||||||||||||||||
| }).toPass({ timeout: 5000 }); | ||||||||||||||||
|
|
||||||||||||||||
| const container = page.locator('#container'); | ||||||||||||||||
|
|
||||||||||||||||
| await expect(container).toHaveScreenshot(screenshot(`checkbox-focus`)); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| test('should render focus indicator when checked', async ({ page, pageUtils }) => { | ||||||||||||||||
| await page.setContent( | ||||||||||||||||
| ` | ||||||||||||||||
| <style> | ||||||||||||||||
| #container { | ||||||||||||||||
| width: fit-content; | ||||||||||||||||
| padding: 10px; | ||||||||||||||||
| } | ||||||||||||||||
| </style> | ||||||||||||||||
|
|
||||||||||||||||
| <ion-app> | ||||||||||||||||
| <div id="container"> | ||||||||||||||||
| <ion-checkbox checked>Checked</ion-checkbox> | ||||||||||||||||
| </div> | ||||||||||||||||
| </ion-app> | ||||||||||||||||
| `, | ||||||||||||||||
| config | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| const checkbox = page.locator('ion-checkbox'); | ||||||||||||||||
|
|
||||||||||||||||
| // The focus listeners attach asynchronously, so the first Tab can miss | ||||||||||||||||
| // them. Retry until `ion-focused` sticks before taking the snapshot. | ||||||||||||||||
| await expect(async () => { | ||||||||||||||||
| await page.evaluate(() => (document.activeElement as HTMLElement | null)?.blur()); | ||||||||||||||||
| await pageUtils.pressKeys('Tab'); | ||||||||||||||||
| await expect(checkbox).toHaveClass(/ion-focused/, { timeout: 250 }); | ||||||||||||||||
| }).toPass({ timeout: 5000 }); | ||||||||||||||||
|
|
||||||||||||||||
| const container = page.locator('#container'); | ||||||||||||||||
|
|
||||||||||||||||
| await expect(container).toHaveScreenshot(screenshot(`checkbox-focus-checked`)); | ||||||||||||||||
| }); | ||||||||||||||||
| }); | ||||||||||||||||
| }); | ||||||||||||||||
Binary file added
BIN
+2.29 KB
...heckbox.e2e.ts-snapshots/checkbox-focus-checked-ios-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.75 KB
...eckbox.e2e.ts-snapshots/checkbox-focus-checked-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.84 KB
...heckbox.e2e.ts-snapshots/checkbox-focus-checked-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.92 KB
...checkbox.e2e.ts-snapshots/checkbox-focus-checked-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.27 KB
...heckbox.e2e.ts-snapshots/checkbox-focus-checked-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.6 KB
...checkbox.e2e.ts-snapshots/checkbox-focus-checked-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+136 Bytes
(110%)
.../basic/checkbox.e2e.ts-snapshots/checkbox-focus-ios-ltr-Mobile-Chrome-linux.png
|
brandyscarney marked this conversation as resolved.
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+436 Bytes
(120%)
...basic/checkbox.e2e.ts-snapshots/checkbox-focus-ios-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+143 Bytes
(100%)
.../basic/checkbox.e2e.ts-snapshots/checkbox-focus-ios-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.74 KB
...t/basic/checkbox.e2e.ts-snapshots/checkbox-focus-md-ltr-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.2 KB
.../basic/checkbox.e2e.ts-snapshots/checkbox-focus-md-ltr-Mobile-Firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.57 KB
...t/basic/checkbox.e2e.ts-snapshots/checkbox-focus-md-ltr-Mobile-Safari-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-2.04 KB
...heckbox.e2e.ts-snapshots/checkbox-in-item-focus-ios-ltr-Mobile-Chrome-linux.png
Binary file not shown.
Binary file removed
BIN
-2.74 KB
...heckbox.e2e.ts-snapshots/checkbox-in-item-focus-ios-ltr-Mobile-Safari-linux.png
Binary file not shown.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.