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

* prevent toggling password & clearing on disabled form controls

* hide clear icon also on readonly
pull/751/head
Buni48 2022-05-11 14:33:27 +02:00 zatwierdzone przez GitHub
rodzic 7bb6c4f0c1
commit 8814746738
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -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"

Wyświetl plik

@ -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"