You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a route that displays a complex form that has various editors associated with it.
Activating a form control opens up an editor in a dialog, for example it might be a date picker, a colour picker, a custom full-screen input on mobile, and so on.
What I want to do is when I am in one of these editors, the browser back button or mobile soft-key for back, should close the dialog, but stay on the current route.
Before Remix, I would have used the window.history API directly to push a fake state for the dialog, something like appending '#dialog' to the current pathname and pushing that.
I can get some of the way if I use window.history, but I am concerned it interferes with the normal behaviour of the router, and also because it seems to re-invoke a loader when IMO it doesn't need to.
By my last point, this is a contrived example, but let's say the route is /customer/invoices/$invoiceId, there is a loader on /customer to load the customer data and all the invoices, so when I navigate to the invoice it does not need to reload anything. I click my editor and I push a fake history /customer/invoices/$invoiceId#dialog. I hit the browser back button, it correctly pops this fake history and returns to the invoice route. BUT, it has triggered an unwanted reload on the /customer route.
I don't really want to add each editor into its own route, I have many, many form fields with editors like this.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have a route that displays a complex form that has various editors associated with it.
Activating a form control opens up an editor in a dialog, for example it might be a date picker, a colour picker, a custom full-screen input on mobile, and so on.
What I want to do is when I am in one of these editors, the browser back button or mobile soft-key for back, should close the dialog, but stay on the current route.
Before Remix, I would have used the window.history API directly to push a fake state for the dialog, something like appending '#dialog' to the current pathname and pushing that.
I can get some of the way if I use window.history, but I am concerned it interferes with the normal behaviour of the router, and also because it seems to re-invoke a loader when IMO it doesn't need to.
By my last point, this is a contrived example, but let's say the route is
/customer/invoices/$invoiceId
, there is a loader on/customer
to load the customer data and all the invoices, so when I navigate to the invoice it does not need to reload anything. I click my editor and I push a fake history/customer/invoices/$invoiceId#dialog
. I hit the browser back button, it correctly pops this fake history and returns to the invoice route. BUT, it has triggered an unwanted reload on the/customer
route.I don't really want to add each editor into its own route, I have many, many form fields with editors like this.
Is there some nice way to do this with Remix?
Beta Was this translation helpful? Give feedback.
All reactions