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

Advanced Select multiple not storing multiple selected values correctly #390

Open
connormccarl opened this issue Jun 13, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@connormccarl
Copy link

connormccarl commented Jun 13, 2024

Summary

The Advanced Select multiple is not storing multiple selected values correctly

Steps to Reproduce

  1. Start up a Nextjs project with Preline package installed
  2. Paste in the example code for Advanced Select multiple: https://preline.co/docs/advanced-select.html#multiple
  3. Print out stored values using your preferred method (I have tested using a form with react-hook-form and separately with controlled components using e.target.selectedOptions)

You will notice that if one option is selected then the stored value array populates with that one value. If multiple values are selected, the stored value array is empty.

When I remove the preline "data-hs-select" property, the html multiple select attribute works as intended, storing all of the selected values in an array.

Values from a html multiple select element are in e.target.selectedOptions. There seems to a bug in preline code that does not add to this array correctly when more than one option is selected.


IN THE DEMO

I recreated the issue. After each option selection, the stored values print out in an alert. You will see clearly that when one value is selected the value is stored correctly, but there is an null array when multiple values are selected.


Versions
Next: 14.2.3
Preline: 2.3.0
React: 18
Tailwind CSS: 3.4.1

Demo Link

https://stackblitz.com/edit/stackblitz-starters-uofooa?file=app%2Fpage.tsx

Expected Behavior

On multiple selected values, they are stored correctly in an array.

Actual Behavior

On multiple selected values, a null array is stored.

Screenshots

https://drive.google.com/drive/folders/1UqJOXks7nCG0Y60eyTBzisdk_v1b8Lq4?usp=sharing

@jahaganiev jahaganiev added the bug Something isn't working label Jul 22, 2024
@oliverhaas
Copy link

This is apparently fixed in 2.4.1, i.e. using the newest preline version in the provided demo works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants