Update value of password field on change event (#22706)

This commit is contained in:
Bram Kragten 2024-11-07 09:53:34 +01:00 committed by GitHub
parent 1e73cebda6
commit 786b9ee8d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -117,8 +117,8 @@ export class HaPasswordField extends LitElement {
.autocapitalize=${this.autocapitalize}
.type=${this._unmaskedPassword ? "text" : "password"}
.suffix=${html`<div style="width: 24px"></div>`}
@input=${this._handleInputChange}
@change=${this._reDispatchEvent}
@input=${this._handleInputEvent}
@change=${this._handleChangeEvent}
></ha-textfield>
<ha-icon-button
toggles
@ -153,11 +153,16 @@ export class HaPasswordField extends LitElement {
}
@eventOptions({ passive: true })
private _handleInputChange(ev) {
private _handleInputEvent(ev) {
this.value = ev.target.value;
}
@eventOptions({ passive: true })
private _handleChangeEvent(ev) {
this.value = ev.target.value;
this._reDispatchEvent(ev);
}
private _reDispatchEvent(oldEvent: Event) {
const newEvent = new Event(oldEvent.type, oldEvent);
this.dispatchEvent(newEvent);