Skip to content

Unset TomSelect after destroying the Stimulus Controller #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2022
Merged

Unset TomSelect after destroying the Stimulus Controller #409

merged 1 commit into from
Aug 9, 2022

Conversation

janklan
Copy link
Contributor

@janklan janklan commented Aug 7, 2022

Q A
Bug fix? yes
New feature? no
Tickets 407
License MIT

Sometimes Stimulus re-uses an instance of a controller after it's destroyed and re-created - for example when a Live Twig Component re-renders. Without unsetting the variable, connect() method thinks TomSelect is already in place, and does nothing.

@janklan janklan changed the title Unset tomSelect after destroying the instance Unset TomSelect after destroying the Stimulus Controller Aug 7, 2022
@@ -41,6 +41,8 @@ export default class extends Controller {

disconnect() {
this.tomSelect.destroy();
// Fixes https://github.com/symfony/ux/issues/407
this.tomSelect = undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, good catch - that was an oversight.

@weaverryan
Copy link
Member

Thanks @janklan!

@weaverryan weaverryan merged commit 53421dd into symfony:2.x Aug 9, 2022
@bendavies
Copy link
Contributor

@weaverryan this failed the build since yarn build wasn't done?

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.

3 participants