Skip to content

Commit d80a377

Browse files
committed
fix(blockSettings): prevent warning on initial read-only mode toggle
1 parent a04c37b commit d80a377

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

docs/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 2.31.1
4+
5+
- `Fix` - Prevent the warning from appearing when `readOnly` mode is initially set to `true`
6+
37
### 2.31.0
48

59
- `New` - Inline tools (those with `isReadOnlySupported` specified) can now be used in read-only mode

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@editorjs/editorjs",
3-
"version": "2.31.0",
3+
"version": "2.31.1",
44
"description": "Editor.js — open source block-style WYSIWYG editor with JSON output",
55
"main": "dist/editorjs.umd.js",
66
"module": "dist/editorjs.mjs",

src/components/modules/toolbar/blockSettings.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
6868
return 'flipper' in this.popover ? this.popover?.flipper : undefined;
6969
}
7070

71+
/**
72+
* Flag that indicates whether the `EditorMobileLayoutToggled` event listener is attached.
73+
*/
74+
private hasMobileLayoutToggleListener = false;
75+
7176
/**
7277
* Page selection utils
7378
*/
@@ -92,6 +97,7 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
9297
}
9398

9499
this.eventsDispatcher.on(EditorMobileLayoutToggled, this.close);
100+
this.hasMobileLayoutToggleListener = true;
95101
}
96102

97103
/**
@@ -100,7 +106,11 @@ export default class BlockSettings extends Module<BlockSettingsNodes> {
100106
public destroy(): void {
101107
this.removeAllNodes();
102108
this.listeners.destroy();
103-
this.eventsDispatcher.off(EditorMobileLayoutToggled, this.close);
109+
110+
if (this.hasMobileLayoutToggleListener) {
111+
this.eventsDispatcher.off(EditorMobileLayoutToggled, this.close);
112+
this.hasMobileLayoutToggleListener = false;
113+
}
104114
}
105115

106116
/**

0 commit comments

Comments
 (0)