fix(input): clear button can now be tabbed to (#21633)

fixes https://github.com/ionic-team/ionic/issues/21549
This commit is contained in:
Liam DeBeasi
2020-07-01 10:13:12 -04:00
committed by GitHub
parent c458523b0d
commit 1dcd9de50a
2 changed files with 10 additions and 2 deletions

View File

@ -147,7 +147,11 @@
appearance: none; appearance: none;
} }
:host(.has-focus.has-value) .input-clear-icon { .input-clear-icon:focus {
opacity: 0.5;
}
:host(.has-value) .input-clear-icon {
visibility: visible; visibility: visible;
} }

View File

@ -323,6 +323,10 @@ export class Input implements ComponentInterface {
} }
} }
private clearTextOnEnter = (ev: KeyboardEvent) => {
if (ev.key === 'Enter') { this.clearTextInput(ev); }
}
private clearTextInput = (ev?: Event) => { private clearTextInput = (ev?: Event) => {
if (this.clearInput && !this.readonly && !this.disabled && ev) { if (this.clearInput && !this.readonly && !this.disabled && ev) {
ev.preventDefault(); ev.preventDefault();
@ -408,9 +412,9 @@ export class Input implements ComponentInterface {
aria-label="reset" aria-label="reset"
type="button" type="button"
class="input-clear-icon" class="input-clear-icon"
tabindex="-1"
onTouchStart={this.clearTextInput} onTouchStart={this.clearTextInput}
onMouseDown={this.clearTextInput} onMouseDown={this.clearTextInput}
onKeyDown={this.clearTextOnEnter}
/>} />}
</Host> </Host>
); );