Skip to content

Commit

Permalink
fix: when dynamically resizing the mathfield, update the selection re…
Browse files Browse the repository at this point in the history
…ctangles
  • Loading branch information
arnog committed Dec 6, 2023
1 parent 42518c4 commit ce9b053
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/editor-mathfield/mathfield-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export class _Mathfield implements Mathfield, KeyboardDelegateInterface {
private connectedToVirtualKeyboard: boolean;

private eventController: AbortController;
private resizeObserver: ResizeObserver;

/**
*
Expand Down Expand Up @@ -444,10 +445,13 @@ If you are using Vue, this may be because you are using the runtime-only build o
// to adjust the UI (popover, etc...)
window.addEventListener('resize', this, { signal });
document.addEventListener('scroll', this, { signal });
this.resizeObserver = new ResizeObserver(() => requestUpdate(this));
this.resizeObserver.observe(this.field);

window.mathVirtualKeyboard.addEventListener(
'virtual-keyboard-toggle',
this
this,
{ signal }
);

if (gKeyboardLayout && !l10n.locale.startsWith(gKeyboardLayout.locale))
Expand Down Expand Up @@ -901,6 +905,8 @@ If you are using Vue, this may be because you are using the runtime-only build o
this.eventController.abort();
(this as any).eventController = undefined;

this.resizeObserver.disconnect();

window.mathVirtualKeyboard.removeEventListener(
'virtual-keyboard-toggle',
this
Expand Down Expand Up @@ -1705,7 +1711,7 @@ If you are using Vue, this may be because you are using the runtime-only build o
)
this.focus({ preventScroll: true });
},
{ once: true }
{ once: true, signal }
);
}
},
Expand Down

0 comments on commit ce9b053

Please sign in to comment.