diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 73a8fc024..e3e4dd9d7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,7 @@ - `Improvement` - The current block reference will be updated in read-only mode when blocks are clicked - `Fix` - codex-notifier and codex-tooltip moved from devDependencies to dependencies in package.json to solve type errors - `Fix` - Handle whitespace input in empty placeholder elements to prevent caret from moving unexpectedly to the end of the placeholder +- `Fix` - Fix the memory leak issue in `Shortcuts` class - `Fix` - Fix when / overides selected text outside of the editor - `DX` - Tools submodules removed from the repository diff --git a/src/components/utils/shortcuts.ts b/src/components/utils/shortcuts.ts index 8cf51ff93..967243d27 100644 --- a/src/components/utils/shortcuts.ts +++ b/src/components/utils/shortcuts.ts @@ -86,7 +86,15 @@ class Shortcuts { const shortcuts = this.registeredShortcuts.get(element); - this.registeredShortcuts.set(element, shortcuts.filter(el => el !== shortcut)); + const filteredShortcuts = shortcuts.filter(el => el !== shortcut); + + if (filteredShortcuts.length === 0) { + this.registeredShortcuts.delete(element); + + return; + } + + this.registeredShortcuts.set(element, filteredShortcuts); } /**