mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-06 13:04:53 +08:00
Fix cursor position when focusing cells with mouse click (#2692)
This commit is contained in:
parent
85e2cd336d
commit
3eefd093de
1 changed files with 20 additions and 12 deletions
|
@ -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") {
|
||||
|
|
Loading…
Add table
Reference in a new issue