Skip to content

Commit 53421dd

Browse files
committed
bug #409 Unset TomSelect after destroying the Stimulus Controller (janklan)
This PR was merged into the 2.x branch. Discussion ---------- Unset TomSelect after destroying the Stimulus Controller | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | [407](#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](https://github.com/symfony/ux/blob/2.x/src/Autocomplete/assets/src/controller.ts#L21-L25). Commits ------- 01916e6 Unset tomSelect after destroying the instance
2 parents 72cacda + 01916e6 commit 53421dd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Autocomplete/assets/src/controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export default class extends Controller {
4141

4242
disconnect() {
4343
this.tomSelect.destroy();
44+
// Fixes https://github.com/symfony/ux/issues/407
45+
this.tomSelect = undefined;
4446
}
4547

4648
#getCommonConfig(): Partial<TomSettings> {

0 commit comments

Comments
 (0)