Skip to content

Commit

Permalink
Added fix for memory leak issue (#2893)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Co-authored-by: Peter Savchenko <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent d950a11 commit d15a8c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 9 additions & 1 deletion src/components/utils/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit d15a8c2

Please sign in to comment.