mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix flaky FormulaEditor test by adjusting focus behavior of FormulaEditor.
Summary: The issue is in the app due to the possibility of subtle differences in order of events. It's hard to trigger a wrong order, but the fix is intended to make it impossible. Test Plan: Running test with a bunch of iterations, to see how reliable it is Reviewers: georgegevoian Reviewed By: georgegevoian Subscribers: georgegevoian Differential Revision: https://phab.getgrist.com/D3918
This commit is contained in:
parent
c5e750abc6
commit
812cded291
@ -375,7 +375,15 @@ export class FormulaEditor extends NewBaseEditor {
|
||||
}
|
||||
// Resize editor in case it is needed.
|
||||
this._formulaEditor.resize();
|
||||
|
||||
// This focus method will try to focus a textarea immediately and again on setTimeout. But
|
||||
// other things may happen by the setTimeout time, messing up focus. The reason the immediate
|
||||
// call doesn't usually help is that this is called on 'mousedown' before its corresponding
|
||||
// focus/blur occur. We can do a bit better by restoring focus immediately after blur occurs.
|
||||
aceObj.focus();
|
||||
const lis = dom.onElem(aceObj.textInput.getElement(), 'blur', e => { lis.dispose(); aceObj.focus(); });
|
||||
// If no blur right away, clear the listener, to avoid unexpected interference.
|
||||
setTimeout(() => lis.dispose(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user