Closed chaddjohnson closed 6 years ago
+1 I'm getting this issue also, same thing with Checkboxs...
I noticed a console log of "Shopify.API.Bar.closeDropdown" when the checkbox and choices are clicked
Hi @chaddjohnson, thanks for reaching out!
You've got two ChoiceLists in the webpack example in your Polaris clone. The second works as expected, but the first one copied from the Polaris style guide needs a couple of changes to work as expected (we're working on clearer style guide examples, sorry for any ambiguity).
onChange
prop, which updates the state when a choice is selected, is missing.selected
prop needs to change dynamically each time a choice is selected (when onChange
is called). Since it's hardcoded as ['hidden']
and it doesn't have the onChange
prop, the selection in the first ChoiceList remains the same. With those two things fixed your first ChoiceList will be good to go.
One quick tip--when you use more than one ChoiceList, it's a good idea to use the optional name
prop. The method you pass as the onChange
prop receives two parameters. The first parameter is the array of values from selected choices and the second is the name
given to the ChoiceList. You can use this name
in your state to hold on to each ChoiceList's array of selected choices.
The code below has the changes mentioned above along with an update to your valueUpdater
method to utilize the ChoiceList names given. @charlesemarsh I hope this helps you as well!
Thank you @chloerice! That works.
Issue summary
Expected behavior
I should be able to select different radio options within a ChoiceList component.
Actual behavior
I am unable to select radio options in a ChoiceList component. Here I am unable to select the "Required" option:
Steps to reproduce the problem
cd examples/webpack
.rm yarn.lock
.yarn install
.yarn start
.http://localhost:8080
.You will see that only the default option, "Hidden," can be selected within the "Choice list" section.
Specifications
⚓️ We’re not accepting pull requests at this time
🗒 This repo is for reporting issues and feature requests only