Fix cursor position when focusing cells with mouse click (#2692)

This commit is contained in:
Jonatan Kłosko 2024-06-28 14:42:50 +02:00 committed by GitHub
parent 85e2cd336d
commit 3eefd093de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -186,21 +186,29 @@ const Cell = {
}
liveEditor.onBlur(() => {
// Prevent from blurring unless the state changes. For example
// when we move cell using buttons the editor should keep focus
if (this.isFocused && this.insertMode) {
this.currentEditor().focus();
}
// We defer the check to happen after all focus/click events have
// been processed, in case the state changes as a result
setTimeout(() => {
// Prevent from blurring unless the state changes. For example
// when we move cell using buttons the editor should keep focus
if (this.isFocused && this.insertMode) {
this.currentEditor().focus();
}
}, 0);
});
liveEditor.onFocus(() => {
// Prevent from focusing unless the state changes. The editor
// uses a contenteditable element, and it may accidentally get
// focus. In Chrome clicking on the right-side of the editor
// gives it focus
if (!this.isFocused || !this.insertMode) {
this.currentEditor().blur();
}
// We defer the check to happen after all focus/click events have
// been processed, in case the state changes as a result
setTimeout(() => {
// Prevent from focusing unless the state changes. The editor
// uses a contenteditable element, and it may accidentally get
// focus. In Chrome clicking on the right-side of the editor
// gives it focus
if (!this.isFocused || !this.insertMode) {
this.currentEditor().blur();
}
}, 0);
});
if (tag === "primary") {