Skip to content

Fix removing resize event handler when multiple instances of AceDiff are created/disposed at the same time#113

Merged
jmthomas merged 1 commit intoace-diff:masterfrom
cluvio:fix-resize-event-removal
May 19, 2025
Merged

Fix removing resize event handler when multiple instances of AceDiff are created/disposed at the same time#113
jmthomas merged 1 commit intoace-diff:masterfrom
cluvio:fix-resize-event-removal

Conversation

@ianformanek
Copy link
Contributor

When multiple instances are created and exist at the same time, the module removeEventHandlers would only contain the onResize handler for the last instance created, causing the removeEventListener in destroy() leaving behind the listeners from the earlier instances.

This then triggers console errors Cannot read property 'offsetHeight' of null, caused by the stray onResize handlers being called with the Ace instance DOM element no longer existing.

The fix simply keeps the removeEventHandlers with the AceEditor instance rather than on the shared module variable.

Fixes #64

empinator added a commit to empinator/ace-diff that referenced this pull request Mar 14, 2024
@jmthomas jmthomas merged commit fcaca2b into ace-diff:master May 19, 2025
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.

In "destroy" method, if user has two or more ace-diff elements, the "removeEventHandlers" only remove the last "onResize" handler.

2 participants