@@ -28,8 +28,8 @@ import {
2828 UnattachedFieldError ,
2929} from './field.js' ;
3030import { Msg } from './msg.js' ;
31+ import * as renderManagement from './render_management.js' ;
3132import * as aria from './utils/aria.js' ;
32- import { Coordinate } from './utils/coordinate.js' ;
3333import * as dom from './utils/dom.js' ;
3434import { Size } from './utils/size.js' ;
3535import * as userAgent from './utils/useragent.js' ;
@@ -630,22 +630,22 @@ export abstract class FieldInput<T extends InputTypes> extends Field<
630630
631631 /** Resize the editor to fit the text. */
632632 protected resizeEditor_ ( ) {
633- const block = this . getSourceBlock ( ) ;
634- if ( ! block ) {
635- throw new UnattachedFieldError ( ) ;
636- }
637- const div = WidgetDiv . getDiv ( ) ;
638- const bBox = this . getScaledBBox ( ) ;
639- div ! . style . width = bBox . right - bBox . left + 'px' ;
640- div ! . style . height = bBox . bottom - bBox . top + 'px' ;
633+ renderManagement . finishQueuedRenders ( ) . then ( ( ) => {
634+ const block = this . getSourceBlock ( ) ;
635+ if ( ! block ) throw new UnattachedFieldError ( ) ;
636+ const div = WidgetDiv . getDiv ( ) ;
637+ const bBox = this . getScaledBBox ( ) ;
638+ div ! . style . width = bBox . right - bBox . left + 'px' ;
639+ div ! . style . height = bBox . bottom - bBox . top + 'px' ;
641640
642- // In RTL mode block fields and LTR input fields the left edge moves,
643- // whereas the right edge is fixed. Reposition the editor.
644- const x = block . RTL ? bBox . right - div ! . offsetWidth : bBox . left ;
645- const xy = new Coordinate ( x , bBox . top ) ;
641+ // In RTL mode block fields and LTR input fields the left edge moves,
642+ // whereas the right edge is fixed. Reposition the editor.
643+ const x = block . RTL ? bBox . right - div ! . offsetWidth : bBox . left ;
644+ const y = bBox . top ;
646645
647- div ! . style . left = xy . x + 'px' ;
648- div ! . style . top = xy . y + 'px' ;
646+ div ! . style . left = `${ x } px` ;
647+ div ! . style . top = `${ y } px` ;
648+ } ) ;
649649 }
650650
651651 /**
@@ -657,7 +657,7 @@ export abstract class FieldInput<T extends InputTypes> extends Field<
657657 * div.
658658 */
659659 override repositionForWindowResize ( ) : boolean {
660- const block = this . getSourceBlock ( ) ;
660+ const block = this . getSourceBlock ( ) ?. getRootBlock ( ) ;
661661 // This shouldn't be possible. We should never have a WidgetDiv if not using
662662 // rendered blocks.
663663 if ( ! ( block instanceof BlockSvg ) ) return false ;
0 commit comments