editable-text: Reset state after programmatic blur()
Regardless of whether the window is active. Fully fixes #4101
This commit is contained in:
parent
b4c5c5d539
commit
f6ee160186
1 changed files with 15 additions and 8 deletions
|
@ -316,15 +316,18 @@
|
||||||
this._ignoredWindowInactiveBlur = true;
|
this._ignoredWindowInactiveBlur = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._ignoredWindowInactiveBlur = false;
|
this._resetStateAfterBlur();
|
||||||
|
};
|
||||||
|
|
||||||
|
_resetStateAfterBlur() {
|
||||||
|
this._ignoredWindowInactiveBlur = false;
|
||||||
this.dispatchEvent(new Event('blur'));
|
this.dispatchEvent(new Event('blur'));
|
||||||
this.classList.remove("focused");
|
this.classList.remove('focused');
|
||||||
this._input.scrollLeft = 0;
|
this._input.scrollLeft = 0;
|
||||||
this._input.setSelectionRange(0, 0);
|
this._input.setSelectionRange(0, 0);
|
||||||
this.removeAttribute("mousedown");
|
this.removeAttribute('mousedown');
|
||||||
delete this._input.dataset.initialValue;
|
delete this._input.dataset.initialValue;
|
||||||
};
|
}
|
||||||
|
|
||||||
_handleKeyDown = (event) => {
|
_handleKeyDown = (event) => {
|
||||||
if (event.key === 'Enter') {
|
if (event.key === 'Enter') {
|
||||||
|
@ -390,6 +393,10 @@
|
||||||
|
|
||||||
blur() {
|
blur() {
|
||||||
this._input?.blur();
|
this._input?.blur();
|
||||||
|
|
||||||
|
// This is a programmatic blur, so reset our state even if the
|
||||||
|
// window is inactive
|
||||||
|
this._resetStateAfterBlur();
|
||||||
}
|
}
|
||||||
|
|
||||||
get focused() {
|
get focused() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue