Skip to content

fix: #18062 MultiSelect is removing previously selected values if sel… #18107

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mehmetcetin01140
Copy link
Contributor

fixes #18062

Copy link

vercel bot commented Apr 18, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
primeng-designer-staging ⬜️ Ignored (Inspect) Visit Preview Apr 18, 2025 10:56am

Copy link

Thank you for your contribution! We will review your PR shortly. Please make sure to manually link it to an issue for proper tracking.

Copy link

Thank you for your contribution! We will review your PR shortly. Please make sure to manually link it to an issue for proper tracking.

const optionValues = [...selectedDisabledOptions, ...visibleOptions].map((option) => this.getOptionValue(option));
const selectedOptionsBeforeSearch = this.filter ? this.getAllVisibleAndNonVisibleOptions().filter((option) => this.isSelected(option) && this.isValidOption(option)) : [];

const optionValues = [...(!this.allSelected() ? selectedOptionsBeforeSearch : []), ...selectedDisabledOptions, ...visibleOptions].map((option) => this.getOptionValue(option));
const value = [...new Set(optionValues)];
Copy link
Contributor

Choose a reason for hiding this comment

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

For efficiency why not remove the conditional !this.allSelected() from const optionValues and update the conditional in const selectedOptionsBeforeSearch to (this.filter && !this.allSelected())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already refactored the code right after committing it. Thanks a lot for the review.

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.

MultiSelect is removing previously selected values if select all is checked after search
2 participants