avoid double handling of keyboard event in rerouter

...and thus fix the bug with restoring keyboard focus to codemirror when closing color picker
This commit is contained in:
tophf 2022-02-12 21:31:35 +03:00
parent f9a2b9de35
commit fcad0ee523

View File

@ -48,8 +48,10 @@
cm.lastActive = Date.now();
};
const onCmBlur = cm => {
rerouteHotkeys.toggle(true);
setTimeout(() => {
/* Delaying to next tick to avoid double-processing of the currently processed keyboard event
* when it bubbles up from CodeMirror to `document` where the rerouter listens */
rerouteHotkeys.toggle(true);
const {wrapper} = cm.display;
wrapper.classList.toggle('CodeMirror-active', wrapper.contains(document.activeElement));
});