Skip to content

Commit b6cb6bf

Browse files
committed
Editor: tabindex fix for Firefox Tab focus loss
1 parent ac1b175 commit b6cb6bf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

editor/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,15 +240,20 @@
240240
if ((e.ctrlKey||e.metaKey) && e.key==='Enter') { e.preventDefault(); runSketch(); }
241241
});
242242

243-
// Fix Tab in Firefox: intercept on the CM textarea directly
243+
// Fix Tab in Firefox
244244
setTimeout(() => {
245+
const cmEl = document.querySelector('.CodeMirror');
245246
const cmTextarea = document.querySelector('.CodeMirror textarea');
247+
if (cmEl) cmEl.setAttribute('tabindex', '-1');
246248
if (cmTextarea) {
249+
cmTextarea.setAttribute('tabindex', '0');
247250
cmTextarea.addEventListener('keydown', e => {
248251
if (e.key === 'Tab') {
249252
e.preventDefault();
250253
e.stopPropagation();
254+
e.stopImmediatePropagation();
251255
editor.replaceSelection(' ');
256+
cmTextarea.focus();
252257
}
253258
}, true);
254259
}

0 commit comments

Comments
 (0)