I have a requirement to allow users to select products or collections.
Two components are used to facilitate this:
ResourcePicker resourceType="Product"
ResourcePicker resourceType="Collection"
resourceType="Collection" returns an empty array for the payload of onSelection when switching between the ResourcePickers
To Reproduce
Create an app using Shopify cli.
create two components where only one is open at a time.
Select a collection using the collection resourceType
Select products using the product resourceType
Select a collection using the collection resourceType
The payload of onSelection often returns an empty array for the collection resource type even when a selection has been made.
Expected behaviour
onSelection is not affected by switching between ResourcePickers of different types.
It should always return the selected resources
Contextual information
<ResourcePicker
open={state.isChoosingProducts}
resourceType="Collection"
selectMultiple={false}
onSelection={ ({selection}) => {
// often this returns any empty selection [] when a ResourcePicker of resourceType="Product" has just been used to select products
}}
Describe the bug
I have a requirement to allow users to select products or collections.
Two components are used to facilitate this: ResourcePicker resourceType="Product" ResourcePicker resourceType="Collection"
resourceType="Collection" returns an empty array for the payload of onSelection when switching between the ResourcePickers
To Reproduce
Create an app using Shopify cli. create two components where only one is open at a time.
Expected behaviour
onSelection is not affected by switching between ResourcePickers of different types. It should always return the selected resources
Contextual information
<ResourcePicker open={state.isChoosingProducts} resourceType="Collection" selectMultiple={false} onSelection={ ({selection}) => { // often this returns any empty selection [] when a ResourcePicker of resourceType="Product" has just been used to select products }}
/>
Packages and versions
Platform
MacBook Pro 2.3 GHz Dual-Core Intel Core i5
Additional context
Built using "shopify-frontend-template-react"