Prevent toggling password & clearing on disabled form controls (#746)

* prevent toggling password & clearing on disabled form controls

* hide clear icon also on readonly
This commit is contained in:
Buni48
2022-05-11 14:33:27 +02:00
committed by GitHub
parent 7bb6c4f0c1
commit 8814746738
2 changed files with 5 additions and 3 deletions

View File

@@ -297,6 +297,7 @@ export default class SlInput extends LitElement {
const hasHelpTextSlot = this.hasSlotController.test('help-text');
const hasLabel = this.label ? true : !!hasLabelSlot;
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
const hasClearIcon = this.clearable && !this.disabled && !this.readonly && this.value.length > 0;
return html`
<div
@@ -378,7 +379,7 @@ export default class SlInput extends LitElement {
@blur=${this.handleBlur}
/>
${this.clearable && this.value.length > 0
${hasClearIcon
? html`
<button
part="clear-button"
@@ -394,7 +395,7 @@ export default class SlInput extends LitElement {
</button>
`
: ''}
${this.togglePassword
${this.togglePassword && !this.disabled
? html`
<button
part="password-toggle-button"

View File

@@ -450,6 +450,7 @@ export default class SlSelect extends LitElement {
const hasSelection = this.multiple ? this.value.length > 0 : this.value !== '';
const hasLabel = this.label ? true : !!hasLabelSlot;
const hasHelpText = this.helpText ? true : !!hasHelpTextSlot;
const hasClearIcon = this.clearable && !this.disabled && hasSelection;
return html`
<div
@@ -530,7 +531,7 @@ export default class SlSelect extends LitElement {
: this.placeholder}
</div>
${this.clearable && hasSelection
${hasClearIcon
? html`
<button
part="clear-button"