Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
85 stars 9 forks source link

Product resource picker bug in iOS #182

Closed charles-tyler closed 1 year ago

charles-tyler commented 1 year ago

Describe the bug

Product resource picker returning duplicate product information on iOS.

To Reproduce

Steps to reproduce the behaviour:

  1. Select a product using the product variant resource picker - https://shopify.dev/docs/apps/tools/app-bridge/actions/resourcepicker

Expected behaviour

Expected one item to be returned, however in a recent iOS Shopify app update two items are returned.

Not present in the POS app.

Contextual information

Packages and versions

List the relevant packages you’re using, and their versions. For example:

Platform

MitchLillie commented 1 year ago

Hi Charles! Thanks for the bug report.

I tried to reproduce this and was unable to. Could you share some more information about the problem you're seeing? In particular:

  1. What options are you initializing ResourcePicker with?
  2. What is the structure of the payload you're getting back from ResourcePicker?
charles-tyler commented 1 year ago

We are initializing it with the following;

We open with our own component for the Resource picker using:

const openProductPicker = () => {
    return getResourcePicker({
      app,
      selectMultiple: 10,
      showDraft: false,
      showArchived: false,
      initialSelectionIds: getInitialSelectionIds(),
      handlePayloadData: handleResourcePickerData
    })
  }

Component getResourcePicker

import { ResourcePicker } from "@shopify/app-bridge/actions"

const getResourcePicker = ({
    app,
    pickCollection = false,

    showHidden = true,
    showVariants = true,
    showDraft = true,
    showArchived = true,
    showDraftBadge = false,
    showArchivedBadge = false,

    selectMultiple = 10,
    initialSelectionIds = [],

    handlePayloadData = () => {}
}) => {

  const productPicker = ResourcePicker.create(app, {
    resourceType: pickCollection?  ResourcePicker.ResourceType.Collection: ResourcePicker.ResourceType.Product,
    options: {
      showHidden,
      showVariants,
      showDraft,
      showArchived,
      showDraftBadge,
      showArchivedBadge,

      selectMultiple,
      initialSelectionIds
    },
  })
  productPicker.dispatch(ResourcePicker.Action.OPEN)
  productPicker.subscribe(ResourcePicker.Action.SELECT, handlePayloadData)
}

export default getResourcePicker
MitchLillie commented 1 year ago

I'm not able to reproduce this bug, either in our internal testing app or in EasyScan on my shop. See video:

https://user-images.githubusercontent.com/5873610/222210730-e02330b8-1fa2-4c65-87ba-83e50827077c.MP4

Can you share what shop you're using for testing? I can try to reproduce the bug there.

MitchLillie commented 1 year ago

@charles-tyler determined that the issue happens specifically when selecting every variant of a product, and I was able to reproduce that case.

Looking at a fix now.

henrytao-me commented 1 year ago

@charles-tyler We have a fix up but missed the release candidate cut off time this week. Can you filter duplicate variantIds from your end as a temporary workaround please? 🙇

MitchLillie commented 1 year ago

Reopening to verify once it's in the mobile build next week.

MitchLillie commented 1 year ago

@charles-tyler This should now be fixed in the latest version of the app, v9.102. Please reopen the issue if you're still having trouble.