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

fix: ensure select value is updated upon select element removal #10846

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

trueadm
Copy link
Contributor

@trueadm trueadm commented Mar 19, 2024

Fixes #9517

Copy link

changeset-bot bot commented Mar 19, 2024

🦋 Changeset detected

Latest commit: 691ebf9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"svelte": patch
---

fix: ensure select value is updated upon select element removal
Copy link
Member

Choose a reason for hiding this comment

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

select option removal?

Comment on lines +102 to +105
var selected_option = select.querySelector(':checked');
if (selected_option === null || get_option_value(selected_option) !== value) {
update('');
}
Copy link
Member

@brunnerh brunnerh Mar 20, 2024

Choose a reason for hiding this comment

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

This does not take <select multiple ...> into account. If three options are selected and one is removed, the remaining two should still be selected (Example).

Comment on lines +108 to +110
observer.observe(select, {
childList: true
});
Copy link
Member

Choose a reason for hiding this comment

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

You also need subtree: true because of <optgroup> (Example).

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.

Svelte 5: select value doesn't match bound value after removing option
2 participants