diff --git a/core/src/components/input/input.ionic.scss b/core/src/components/input/input.ionic.scss index 68a7f64e3f..3fd34df09b 100644 --- a/core/src/components/input/input.ionic.scss +++ b/core/src/components/input/input.ionic.scss @@ -21,6 +21,44 @@ min-height: 48px; } +// Input Clear Button +// ---------------------------------------------------------------- + +.input-clear-icon { + width: 16px; + height: 16px; + + color: #{$ionic-color-neutral-500}; +} + +.input-clear-icon.ion-focused { + border-radius: #{$ionic-border-radius-rounded-small}; + + outline: #{$ionic-border-size-medium} solid #{$ionic-color-primary-100}; + + opacity: 1; +} + +.input-clear-icon ion-icon { + width: 100%; + height: 100%; +} + +/** + * The clear button should be visible if the native input + * OR any other interactive elements in the component (the + * clear button, slotted buttons, etc.) are focused. If we + * only looked at the native input, tabbing to the clear + * button would immediately hide it. + * + * Note that the clear button also requires the native input + * to have any value, but this is not specific to the ionic + * theme, so it is handled elsewhere. + */ +:host(:not(:focus-within)) .input-clear-icon { + display: none; +} + // Ionic Input Shapes // -------------------------------------------------- @@ -69,7 +107,7 @@ // color for the text within the input --color: #{tokens.$ionic-color-neutral-400}; --background: #{tokens.$ionic-color-neutral-10}; - + pointer-events: none; } diff --git a/core/src/components/input/input.tsx b/core/src/components/input/input.tsx index 8c76d54c03..b6263e30ae 100644 --- a/core/src/components/input/input.tsx +++ b/core/src/components/input/input.tsx @@ -729,7 +729,7 @@ export class Input implements ComponentInterface { } render() { - const { disabled, fill, readonly, shape, inputId, el, hasFocus, clearInputIcon } = this; + const { disabled, fill, readonly, shape, inputId, el, hasFocus, clearInput, clearInputIcon } = this; const theme = getIonTheme(this); const value = this.getValue(); const size = this.getSize(); @@ -835,11 +835,11 @@ export class Input implements ComponentInterface { onCompositionend={this.onCompositionEnd} {...this.inheritedAttributes} /> - {this.clearInput && !readonly && !disabled && ( + {clearInput && !readonly && !disabled && (