Skip to content

Commit 38c6a9d

Browse files
committed
fix: race condition
pointerdown event from inner iframe is not fast enough in some cases, so wait a little before deciding if we should refocus the editor
1 parent 66f51bb commit 38c6a9d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/routes/tutorial/[slug]/Editor.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@
232232
233233
<svelte:window
234234
on:pointerdown={(e) => {
235-
console.log(`pointerdown ${container.contains(e.target)}`);
236235
if (!container.contains(/** @type {HTMLElement} */ (e.target))) {
237236
preserve_editor_focus = false;
238237
}
@@ -253,18 +252,19 @@
253252
254253
setTimeout(() => {
255254
preserve_editor_focus = true;
256-
}, 100);
255+
}, 200);
257256
}
258257
}}
259258
on:focusin={() => {
260259
preserve_editor_focus = true;
261260
}}
262261
on:focusout={() => {
263-
if (preserve_editor_focus) {
264-
setTimeout(() => {
262+
// Little timeout, because inner postMessage event might take a little
263+
setTimeout(() => {
264+
if (preserve_editor_focus) {
265265
instance?.editor.focus();
266-
}, 0);
267-
}
266+
}
267+
}, 100);
268268
}}
269269
/>
270270
</div>

0 commit comments

Comments
 (0)