Zaydme / strapi-plugin-multi-select

A strapi custom field for a multi select input.
https://www.npmjs.com/package/strapi-plugin-multi-select
MIT License
40 stars 21 forks source link

Empty field even if value stored in database #28

Open 5ika opened 8 months ago

5ika commented 8 months ago

I'm using last version of Strapi (v4.20.5). When I load a page with the custom field, the field is always empty, even if it has data stored.

The problem I see: There are two renders of MultiSelect component. A first one with value props empty ('') and a second one with the filled value. But as it uses the defaultValue props of React Select to provide the value, the first empty value is kept.

If I replace defaultValue by value in React Select props, field is correctly filled.

Does anyone else have the same problem with the last version of Strapi ?

5ika commented 5 months ago

For those who need this fix, you can find a modified version of the plugin here => https://github.com/5ika/strapi-plugin-multi-select

# Using Yarn
yarn add strapi-plugin-multi-select@https://github.com/5ika/strapi-plugin-multi-select.git

# Or using NPM
npm install git+https://github.com/5ika/strapi-plugin-multi-select.git
kristiczk commented 4 months ago

For those who need this fix, you can find a modified version of the plugin here => https://github.com/5ika/strapi-plugin-multi-select

# Using Yarn
yarn add strapi-plugin-multi-select@https://github.com/5ika/strapi-plugin-multi-select.git

# Or using NPM
npm install git+https://github.com/5ika/strapi-plugin-multi-select.git

Thank you!

Zaydme commented 1 month ago

Hey @5ika, thank you for the fix, if you don't mind creating a PR, that would be great.