Skip to content
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

[Autocomplete] Reset TomSelect when updating controller attributes #1505

Merged
merged 1 commit into from
Dec 23, 2024

Conversation

pierredup
Copy link
Contributor

@pierredup pierredup commented Feb 15, 2024

Q A
Bug fix? yes
New feature? no
Issues Fix #1500
License MIT

When using remote data for Autocomplete, the mutation observer is not started, so the select cannot be reset when some options change (E.G when limiting the options returned after selecting other options using extra_options from #1322).

Instead, we start the mutation observer when using remote data. When the observer runs and checks if the options have changes, we explicitly set the areOptionsEquivalent to true, since the page will just render an empty select. We also check if any of the data-autocomplete attributes changes and forces a reset (E.G using extra_options, the data-autocomplete-url value can be different when using extra options, so we reset the select when this attribute changes).

This fixes only one of the issues from #1500, I'll investigate the other issues and create separate PRs.

@carsonbot carsonbot added the Status: Needs Review Needs to be reviewed label Feb 15, 2024
@momocode-de
Copy link

I also need this fix. What is the status here?

@pierredup pierredup force-pushed the autocomplete-remote-options branch from 55cc7a2 to d14a526 Compare November 20, 2024 13:31
Copy link

github-actions bot commented Nov 20, 2024

📊 Packages dist files size difference

Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
Please review the changes and make sure they are expected.

FileBefore (Size / Gzip)After (Size / Gzip)
Autocomplete
controller.d.ts 1.82 kB / 611 B 1.84 kB+2% 📈 / 619 B+1% 📈
controller.js 16.69 kB / 3.96 kB 16.71 kB0% / 3.97 kB0%

@arrabiata-asanz
Copy link

thank you to everyone that participated in the bug fix!
@weaverryan Are you merging the branch soon?

@smnandre
Copy link
Member

Hey @pierredup, i'm reviving this PR, hoping it's still something you'd like to merge!

How "ready-to-merge" are these changes? Is there anything i need to check in particular?

Thank you!

@pierredup
Copy link
Contributor Author

Hi @smnandre , there's nothing outstanding on this from my side, so I think it's ready to be merged

@smnandre
Copy link
Member

@pierredup great, LGTM!

Could you rebase and add an entry in the src/Autocomplete/CHANGELOG.md (2.23) ?

@pierredup pierredup force-pushed the autocomplete-remote-options branch from 2fbae82 to 9ec287f Compare December 23, 2024 14:35
@smnandre smnandre force-pushed the autocomplete-remote-options branch from 9ec287f to d8fb3fb Compare December 23, 2024 14:55
@smnandre
Copy link
Member

Thanks for your patience! :)

@smnandre smnandre merged commit f8ed736 into symfony:2.x Dec 23, 2024
60 checks passed
@smnandre smnandre added Status: Reviewed Has been reviewed by a maintainer Feature New Feature Autocomplete and removed Status: Needs Review Needs to be reviewed labels Dec 23, 2024
@pierredup pierredup deleted the autocomplete-remote-options branch December 23, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Autocomplete Feature New Feature Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Autocomplete][LiveComponent] Select box doesn't reset when used in a live component
6 participants