fix: add disconnect() cleanup to Stimulus controllers#4249
Merged
Paul-Bob merged 1 commit intoavo-hq:mainfrom Feb 10, 2026
Merged
Conversation
…ation Several Stimulus controllers initialize third-party libraries and event listeners in connect() without tearing them down in disconnect(). During Turbo navigation, this causes null reference errors (e.g. Honeybadger Changes: - tags_field: destroy Tagify instance - easy_mde: call toTextArea() to restore textarea - tippy + preview: destroy Tippy instances - table_row: store bound handler refs for proper removal - record_selector: fix broken removeEventListener (bind() created non-matching refs) and inconsistent keydown/keyup removal - search: unbind Mousetrap keyboard shortcuts - media_library_attach: remove programmatic file input to prevent duplicates on reconnect
daf79d9 to
35110cf
Compare
Contributor
Author
|
I noticed some of these errors over the years, but finally got motivated to fix them. Claude found some other issues along the way. I've tested all myself manually in my app, except for the EasyMDE fix but it seems pretty benign. Hope this helps! |
Paul-Bob
approved these changes
Feb 10, 2026
Contributor
Paul-Bob
left a comment
There was a problem hiding this comment.
LGTM!
Thank you @rickychilcott for this contribution!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeError: Cannot read properties of null (reading 'scrollTop')) and similar errors caused by Stimulus controllers not cleaning up indisconnect()disconnect()to 7 controllers:tags_field,easy_mde,tippy,preview,table_row,media_library_attach,searchremoveEventListenerinrecord_selector(.bind()created non-matching refs so removal was a no-op)Test plan