Skip to content

Commit 4e971bd

Browse files
fix: fix same selection check for inline toolbar
1 parent e19eb4a commit 4e971bd

File tree

1 file changed

+4
-4
lines changed
  • src/components/modules

1 file changed

+4
-4
lines changed

src/components/modules/ui.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default class UI extends Module<UINodes> {
5050
/**
5151
* The actual cached selection.
5252
*/
53-
private prevSelection: any = null;
53+
private prevSelection: string | null = null;
5454

5555
/**
5656
* Editor.js UI CSS class names
@@ -806,10 +806,10 @@ export default class UI extends Module<UINodes> {
806806
private selectionChanged(): void {
807807
const { CrossBlockSelection, BlockSelection } = this.Editor;
808808
const focusedElement = Selection.anchorElement;
809-
const currentSelection = window.getSelection();
809+
const currentSelection = window.getSelection()?.toString() ?? null;
810810

811-
const sameSelection = currentSelection == this.prevSelection && currentSelection;
812-
const sameFocus = this.prevSelectionAnchorElement == focusedElement && focusedElement;
811+
const sameSelection = (currentSelection == this.prevSelection) && !!currentSelection;
812+
const sameFocus = (focusedElement == this.prevSelectionAnchorElement) && !!focusedElement;
813813

814814
if (sameSelection && sameFocus) {
815815
return;

0 commit comments

Comments
 (0)