Skip to content

Commit

Permalink
fix: persist focus when switching tabs (#2301)
Browse files Browse the repository at this point in the history
For the callbacks related to persisting focus when switching tabs, switched from a timeout based approach to cancel the callbacks to a method that looks for change in focus. The timeout based method was not working on Chrome and Firefox in Windows. The new approach still ensures that only the most recent math-field element will have a `visibilitychange` callback associated with it.
  • Loading branch information
mgreminger committed May 23, 2024
1 parent 69e0374 commit dbf5476
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/editor-mathfield/mathfield-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1729,11 +1729,7 @@ If you are using Vue, this may be because you are using the runtime-only build o
{ once: true, signal }
);

// If we haven't received a visibility change after a short delay,
// stop waiting for it (the delay has to be longer than at least
// 16ms: the documents that are not visible are throttled by the
// browser)
setTimeout(() => controller.abort(), 100);
document.addEventListener('focusin', () => controller.abort(), { once: true });
}

onInput(text: string): void {
Expand Down

0 comments on commit dbf5476

Please sign in to comment.