Shopify / shopify-app-bridge

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

useNavigate hook to a given Order won't work #148

Closed mxp-qk closed 1 year ago

mxp-qk commented 1 year ago

Describe the bug

The useNavigate hook should allow to

Navigate to Shopify admin by using a section name and an optional resource ID.

The given exemple works well for a given collection but when trying to navigate to a given order the hook won't work

// OK
<Link
  onClick={() =>
    navigate({ name: "Collection", resource: { id: "123" } })
  }
>
  Order Number
</Link>
<Link
  onClick={() =>
    navigate({ name: "Order" })
  }
>
  Order Number
</Link>

// NOK
<Link
  onClick={() =>
    navigate({ name: "Order", resource: { id: "123" } })
  }
>
  Order Number
</Link>

[Doc](Navigate to Shopify admin by using a section name and an optional resource ID.)

To Reproduce

Steps to reproduce the behaviour:

  1. Launch the app with a link to a given order
  2. Click on the link
  3. See error

Expected behaviour

The link should navigate to the order page

Contextual information

Packages and versions

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

Platform

charlesdobson commented 1 year ago

Hi @mxp-qk!

Are you able to upgrade to the latest versions and try again? That's version 3.3.2. I'm not currently able to reproduce the issue (I can navigate to an individual order page okay).

mxp-qk commented 1 year ago

Hi @charlesdobson,

I bootstrap the project with npm init @shopify/app@latest two days ago so I didn't check the latest version, my bad.

It didn't solve the issue but this did :

<Link
  onClick={() =>
    navigate({ name: "Order", resource: { id: id.toString() } })
  }
>
  Order Number
</Link>

In my example and working test the id was a primitive string but in my real use cas the id come from the API and was a number.

charlesdobson commented 1 year ago

Ah, good to know! Maybe it would be better if we were to accept numbers and convert them to a string on our end. I will take a look into it. Glad you got it working for now though!