Skip to content

Commit

Permalink
Do not synchronize the minimap scroll if an editor is not ready.
Browse files Browse the repository at this point in the history
  • Loading branch information
pomek committed Feb 22, 2024
1 parent 90d8ca4 commit 6c925de
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/ckeditor5-minimap/src/minimap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export default class Minimap extends Plugin {
* @inheritDoc
*/
public override destroy(): void {
super.destroy();

this._minimapView!.destroy();
this._minimapView!.element!.remove();
}
Expand All @@ -91,6 +93,10 @@ export default class Minimap extends Plugin {
this._initializeMinimapView();

this.listenTo( editor.editing.view, 'render', () => {
if ( editor.state !== 'ready' ) {
return;
}

this._syncMinimapToEditingRootScrollPosition();
} );

Expand Down Expand Up @@ -205,11 +211,7 @@ export default class Minimap extends Plugin {

// The intersection helps to change the tracker height when there is a lot of padding around the root.
// Note: It is **essential** that the height is set first because the progress depends on the correct tracker height.
const intersection = scrollableRootAncestorRect.getIntersection( editingRootRect );

if ( intersection ) {
minimapView.setPositionTrackerHeight( intersection.height );
minimapView.setScrollProgress( scrollProgress );
}
minimapView.setPositionTrackerHeight( scrollableRootAncestorRect.getIntersection( editingRootRect )!.height );
minimapView.setScrollProgress( scrollProgress );
}
}

0 comments on commit 6c925de

Please sign in to comment.