mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
Toggle visibility of the clear button (#1496)
This commit is contained in:
@@ -407,7 +407,9 @@ export default class SlInput extends ShoelaceElement implements ShoelaceFormCont
|
||||
const hasLabel = this.label ? true : !!hasLabelSlot;
|
||||
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
|
||||
const hasClearIcon =
|
||||
this.clearable && !this.disabled && !this.readonly && (typeof this.value === 'number' || this.value.length > 0);
|
||||
this.clearable && !this.disabled && !this.readonly;
|
||||
const hasClearIconVisible =
|
||||
hasClearIcon && (typeof this.value === 'number' || this.value.length > 0);
|
||||
|
||||
return html`
|
||||
<div
|
||||
@@ -497,6 +499,7 @@ export default class SlInput extends ShoelaceElement implements ShoelaceFormCont
|
||||
type="button"
|
||||
aria-label=${this.localize.term('clearEntry')}
|
||||
@click=${this.handleClearClick}
|
||||
style="visibility: ${hasClearIconVisible?'visible':'hidden'}"
|
||||
tabindex="-1"
|
||||
>
|
||||
<slot name="clear-icon">
|
||||
|
||||
Reference in New Issue
Block a user