Skip to content

Commit d15a8c2

Browse files
obafemitayoromotayor-testlioneSpecc
authored
Added fix for memory leak issue (#2893)
* Added fix for memory leak issue * Documented the fix in docs/CHANGELOG.md * v2.31.0 * Documented the fix in docs/CHANGELOG.md * Documented the fix in docs/CHANGELOG.md * Documented the fix in docs/CHANGELOG.md * Documented the fix in docs/CHANGELOG.md --------- Co-authored-by: Omotayo Obafemi <omotayo@testlio.com> Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
1 parent d950a11 commit d15a8c2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- `Improvement` - The current block reference will be updated in read-only mode when blocks are clicked
1212
- `Fix` - codex-notifier and codex-tooltip moved from devDependencies to dependencies in package.json to solve type errors
1313
- `Fix` - Handle whitespace input in empty placeholder elements to prevent caret from moving unexpectedly to the end of the placeholder
14+
- `Fix` - Fix the memory leak issue in `Shortcuts` class
1415
- `Fix` - Fix when / overides selected text outside of the editor
1516
- `DX` - Tools submodules removed from the repository
1617

src/components/utils/shortcuts.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,15 @@ class Shortcuts {
8686

8787
const shortcuts = this.registeredShortcuts.get(element);
8888

89-
this.registeredShortcuts.set(element, shortcuts.filter(el => el !== shortcut));
89+
const filteredShortcuts = shortcuts.filter(el => el !== shortcut);
90+
91+
if (filteredShortcuts.length === 0) {
92+
this.registeredShortcuts.delete(element);
93+
94+
return;
95+
}
96+
97+
this.registeredShortcuts.set(element, filteredShortcuts);
9098
}
9199

92100
/**

0 commit comments

Comments
 (0)