fix(input): clear button uses contrast when setting color on item (#26592)

resolves #26337
This commit is contained in:
Liam DeBeasi
2023-01-17 11:07:08 -05:00
committed by GitHub
parent 911b1d496e
commit a31e1e594d
9 changed files with 20 additions and 4 deletions

View File

@ -158,12 +158,14 @@
background-color: transparent; background-color: transparent;
background-repeat: no-repeat; background-repeat: no-repeat;
color: $text-color-step-400;
visibility: hidden; visibility: hidden;
appearance: none; appearance: none;
} }
.input-clear-icon ion-icon { :host(.in-item-color) .input-clear-icon {
color: $text-color-step-400; color: inherit;
} }
/** /**

View File

@ -12,7 +12,7 @@ import type {
} from '../../interface'; } from '../../interface';
import type { Attributes } from '../../utils/helpers'; import type { Attributes } from '../../utils/helpers';
import { inheritAriaAttributes, debounceEvent, findItemLabel, inheritAttributes } from '../../utils/helpers'; import { inheritAriaAttributes, debounceEvent, findItemLabel, inheritAttributes } from '../../utils/helpers';
import { createColorClasses } from '../../utils/theme'; import { createColorClasses, hostContext } from '../../utils/theme';
/** /**
* @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use. * @virtualProp {"ios" | "md"} mode - The mode determines which platform styles to use.
@ -454,6 +454,7 @@ export class Input implements ComponentInterface {
[mode]: true, [mode]: true,
'has-value': this.hasValue(), 'has-value': this.hasValue(),
'has-focus': this.hasFocus, 'has-focus': this.hasFocus,
'in-item-color': hostContext('ion-item.ion-color', this.el),
})} })}
> >
<input <input

View File

@ -185,7 +185,7 @@ test.describe('input: clear button', () => {
*/ */
test('should keep the input focused when the clear button is pressed', async ({ page }) => { test('should keep the input focused when the clear button is pressed', async ({ page }) => {
await page.setContent(` await page.setContent(`
<ion-input value="abc" clear-input="true"></ion-searchbar> <ion-input value="abc" clear-input="true"></ion-input>
`); `);
const input = page.locator('ion-input'); const input = page.locator('ion-input');
@ -200,4 +200,17 @@ test.describe('input: clear button', () => {
await expect(nativeInput).toBeFocused(); await expect(nativeInput).toBeFocused();
}); });
test('should inherit color when used in item with color property', async ({ page }) => {
await page.setContent(`
<ion-item color="primary">
<ion-input value="Text" clear-input="true"></ion-input>
</ion-item>
`);
const item = page.locator('ion-item');
expect(await item.screenshot()).toMatchSnapshot(
`input-with-clear-button-item-color-${page.getSnapshotSettings()}.png`
);
});
}); });