File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ interface UINodes {
41
41
* @property {Element } nodes.redactor - <ce-redactor>
42
42
*/
43
43
export default class UI extends Module < UINodes > {
44
+ /**
45
+ * This is the cached selection anchor element in order to check if the selection
46
+ * has actually changed and prevent inifinite firing and handling of the selectionchange event.
47
+ */
48
+ private prevSelectionAnchorElement : Element | null = null ;
49
+
44
50
/**
45
51
* Editor.js UI CSS class names
46
52
*
@@ -787,6 +793,7 @@ export default class UI extends Module<UINodes> {
787
793
}
788
794
}
789
795
796
+
790
797
/**
791
798
* Handle selection changes on mobile devices
792
799
* Uses for showing the Inline Toolbar
@@ -795,6 +802,12 @@ export default class UI extends Module<UINodes> {
795
802
const { CrossBlockSelection, BlockSelection } = this . Editor ;
796
803
const focusedElement = Selection . anchorElement ;
797
804
805
+ if ( this . prevSelectionAnchorElement == focusedElement ) {
806
+ return ;
807
+ }
808
+
809
+ this . prevSelectionAnchorElement = focusedElement ;
810
+
798
811
if ( CrossBlockSelection . isCrossBlockSelectionStarted ) {
799
812
// Removes all ranges when any Block is selected
800
813
if ( BlockSelection . anyBlockSelected ) {
You can’t perform that action at this time.
0 commit comments