@@ -264,9 +264,9 @@ export const buildOnFocusListner = (onTrigger: (cursor: CursorInfo) => void) =>
264264 let relativeLeft = coords . left - editorRect . left ;
265265
266266 const HELPER_PANE_WIDTH = 300 ;
267- const viewportWidth = window . innerWidth ;
268- const absoluteLeft = coords . left ;
269- const overflow = absoluteLeft + HELPER_PANE_WIDTH - viewportWidth ;
267+ const editorWidth = editorRect . width ;
268+ const relativeRight = relativeLeft + HELPER_PANE_WIDTH ;
269+ const overflow = relativeRight - editorWidth ;
270270
271271 if ( overflow > 0 ) {
272272 relativeLeft -= overflow ;
@@ -302,9 +302,9 @@ export const buildOnSelectionChange = (onTrigger: (cursor: CursorInfo) => void)
302302 let relativeLeft = coords . left - editorRect . left ;
303303
304304 const HELPER_PANE_WIDTH = 300 ;
305- const viewportWidth = window . innerWidth ;
306- const absoluteLeft = coords . left ;
307- const overflow = absoluteLeft + HELPER_PANE_WIDTH - viewportWidth ;
305+ const editorWidth = editorRect . width ;
306+ const relativeRight = relativeLeft + HELPER_PANE_WIDTH ;
307+ const overflow = relativeRight - editorWidth ;
308308
309309 if ( overflow > 0 ) {
310310 relativeLeft -= overflow ;
@@ -367,9 +367,9 @@ export const buildOnChangeListner = (onTrigeer: (newValue: string, cursor: Curso
367367 let relativeLeft = coords . left - editorRect . left ;
368368
369369 const HELPER_PANE_WIDTH = 300 ;
370- const viewportWidth = window . innerWidth ;
371- const absoluteLeft = coords . left ;
372- const overflow = absoluteLeft + HELPER_PANE_WIDTH - viewportWidth ;
370+ const editorWidth = editorRect . width ;
371+ const relativeRight = relativeLeft + HELPER_PANE_WIDTH ;
372+ const overflow = relativeRight - editorWidth ;
373373
374374 if ( overflow > 0 ) {
375375 relativeLeft -= overflow ;
0 commit comments