Closed Jolsty closed 8 months ago
Hi, did anyone manage to take a look at this problem? Do you need more information to replicate it?
Bump
This is the intended behavior. Navigation from modals should only happen after a user interacts with a link. We do not recommend or support navigation programmatically, or on button presses from the primary or secondary buttons from the modal.
We removed the navigate API from action extension to clarify this, it is only intended for use in block extensions to launch the accompanying action extension.
Hey @AaronSpringut , I think programatic navigation would be good to allow.
The scenario I can't seem to work around is saving the main resource and seeing the data update on the main resource page. Using navigation.navigate() would allow you to force a reload of the page and get new data after you save from your admin action.
The only option I have right now (as far as I can tell) is to add a <Link>
inside of the modal content area that displays after the data gets persisted to reload the page. The issue is made more difficult by the fact that the primaryAction and secondaryAction buttons do not allow href navigation either on AdminAction component. It all feels very clunky to accomplish this basic use case.
My Wishlist:
Thanks
@AaronSpringut what about the following use case in an admin extension?
You can't achieve the opening of the file in a new tab, even though it all happens as a result of a user action (the button click).
The only way around that I can think of is then to render another button, prompting the user to open the file.
Actually, we could work around the above by leaving the Button
component in a loading state until the document URL is fetched and then activating the button after setting the href
and target
. This adds complexity for us elsewhere but should achieve what we want.
Please list the package(s) involved in the issue, and include the version you are using
Shopify Remix App dependencies
Extension dependencies
Extension TOML configuration
Describe the bug
I am trying to implement a very basic prototype of an admin extension in product-index where I would create a product. My problem lies after I run the mutation to create the product: the response result gives me the
productId
which I would like to use for navigating programmatically towards the new product by usingnavigation.navigate(`shopify:admin/products/${data.product.id}`);
but this does not work. I don't see any console errors and I am not redirected to the product details page.
Note that the
navigation
object, as per the documentation, comes from this hook:Note that navigating in the same way by using this piece of code actually works, so I would expect the same behaviour from the navigation API.
I would like to know if there is something wrong I am doing or I am missing something.
Steps to reproduce the behavior:
Expected behavior
I expected to be redirected to the product details page.