Skip to content

Commit 2eb1dbd

Browse files
authored
fix(input): add focus ring to the clear input button for ionic theme (#29409)
1 parent 5c7a782 commit 2eb1dbd

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

core/src/components/input/input.ionic.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
color: #{$ionic-color-neutral-500};
7070
}
7171

72-
.input-clear-icon.ion-focused {
72+
.input-clear-icon:focus-visible {
7373
@include border-radius($ionic-border-radius-rounded-small);
7474

7575
outline: #{$ionic-border-size-medium} solid #{$ionic-color-primary-100};

core/src/components/input/input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ export class Input implements ComponentInterface {
843843
<button
844844
aria-label="reset"
845845
type="button"
846-
class="input-clear-icon ion-focusable"
846+
class="input-clear-icon"
847847
onPointerDown={(ev) => {
848848
/**
849849
* This prevents mobile browsers from

core/src/components/input/test/basic/input.e2e.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ configs({ modes: ['ionic-md'] }).forEach(({ title, screenshot, config }) => {
154154
await expect(input).toHaveScreenshot(screenshot(`input-with-clear-button`));
155155
});
156156

157-
test('should not have visual regressions when clear button is focused', async ({ page }) => {
157+
test('should not have visual regressions when clear button is focused', async ({ page, pageUtils }) => {
158158
// extra padding around input ensures focus ring doesn't get cut off at screenshot edges
159159
await page.setContent(
160160
`
@@ -180,9 +180,7 @@ configs({ modes: ['ionic-md'] }).forEach(({ title, screenshot, config }) => {
180180
await input.evaluate((el: HTMLIonInputElement) => el.setFocus());
181181
await page.waitForChanges();
182182

183-
const clearButton = input.locator('.input-clear-icon');
184-
clearButton.evaluate((el: HTMLElement) => el.classList.add('ion-focused'));
185-
await page.waitForChanges();
183+
await pageUtils.pressKeys('Tab');
186184

187185
const container = page.locator('#container');
188186
await expect(container).toHaveScreenshot(screenshot(`input-clear-button-focused`));
@@ -192,7 +190,7 @@ configs({ modes: ['ionic-md'] }).forEach(({ title, screenshot, config }) => {
192190

193191
configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, config }) => {
194192
test.describe(title('input: clear button in ionic theme, functionality checks'), () => {
195-
test('should show clear button when any part of input is focused', async ({ page }) => {
193+
test('should show clear button when any part of input is focused', async ({ page, pageUtils }) => {
196194
await page.setContent(
197195
`
198196
<ion-input
@@ -214,7 +212,7 @@ configs({ modes: ['ionic-md'], directions: ['ltr'] }).forEach(({ title, config }
214212
await expect(clearButton).toBeVisible();
215213

216214
// ensure blurring native input doesn't immediately hide clear button
217-
await page.keyboard.press('Tab');
215+
await pageUtils.pressKeys('Tab');
218216
await expect(clearButton).toBeFocused();
219217
await expect(clearButton).toBeVisible();
220218
});

0 commit comments

Comments
 (0)