-
-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #1502 [Autocomplete] Fix 2 bugs where TomSelect would reset when …
…not necessary (weaverryan) This PR was merged into the 2.x branch. Discussion ---------- [Autocomplete] Fix 2 bugs where TomSelect would reset when not necessary | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Issues | Fix #1499 | License | MIT Hi! The Autocomplete component "resets" the TomSelect instance under certain situations: * A) The underlying `<option>` elements have changed * B) The `<select>` changed its `multiple` attribute Both of these situations had a bug: * A) If there was no empty `<option value"">` element, then each time a value was selected, it incorrectly looked like the options had changed, triggering a reset. * B) If the `<select multiple>` attribute was used without the `multiple="multiple"`, it would incorrectly look like the multiple value was changing, when in fact it was just varying between these 2 valid formats. In both cases, when combined with LiveComponents, an infinite loop was triggered. That's because, as part of the reset process, when we recreate the TomSelect instance, we "select" the original value. This triggers a `change` event, causing LiveComponents to re-render. On its own , that's fine. But the re-render would trigger one of the bugs above, which would trigger another reset and another re-render. Cheers! Commits ------- 7a801fa [Autocomplete] Fix 2 bugs where TomSelect would reset when not necessary
- Loading branch information
Showing
3 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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