rails / request.js

MIT License
389 stars 28 forks source link

Multiselect is only sending the last selected option #52

Closed luismoyano closed 1 year ago

luismoyano commented 1 year ago

Hello!

Having a form with a multiselect where all the options are selected, only the last one is sent to the server.

How to reproduce:

This happens on utils.js on the merge entries method: The entries for a multiselect have identical keys looking similar to my_model[my_multi_field][] and different values which are deleted and replaced for the last one.

marcelolx commented 1 year ago

I think this PR fixed that https://github.com/rails/request.js/pull/50

luismoyano commented 1 year ago

Ah yes! I can see it now, I'm using request.js from npm directly, is there any chance to update it there or do I need to use the gem? (I'd rather not to)

marcelolx commented 1 year ago

@luismoyano you saying you have defined request.js as a dependency on your package.json file? If so, you can just change the following

"@rails/request.js": "^0.0.6",

to

"@rails/request.js": "https://github.com/rails/request.js.git#main",

That will use what is available on main.

marcelolx commented 1 year ago

btw, I just published v0.0.7 https://www.npmjs.com/package/@rails/request.js/v/0.0.7

marcelolx commented 1 year ago

can you test and see if it works? I'll close the issue, but let me know if the problem persists and we can work on a fix