Skip to content

fix(ui): remove blocks holder listeners and detach it on destroy#174

Open
SAY-5 wants to merge 1 commit into
editor-js:mainfrom
SAY-5:fix/blocks-ui-listener-cleanup
Open

fix(ui): remove blocks holder listeners and detach it on destroy#174
SAY-5 wants to merge 1 commit into
editor-js:mainfrom
SAY-5:fix/blocks-ui-listener-cleanup

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 20, 2026

Copy link
Copy Markdown

Closes #170

BlocksUI attaches beforeinput and keydown listeners to the blocks holder in #prepareBlocksHolder() but destroy() never removes them, and the holder itself is never detached. If a holder is reused or a new instance is created, the old listeners keep firing alongside the new ones (duplicate BeforeInputUIEvent dispatches and stale undo/redo handling).

This wires both listeners to a single AbortController and calls .abort() in destroy(), which is the pattern the issue suggested. destroy() now also detaches #blocksHolder, and EditorjsUI.destroy() (previously a no-op) removes its #editorWrapper so the whole subtree comes off the page.

The ui package has no test runner wired up yet (no Blocks.spec.ts and no test script), so this doesn't add a spec. Happy to follow up with one if you want the test harness set up here.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BlocksUI doesn't remove its blocksHolder DOM event listeners (or the holder itself) on destroy()

1 participant