SoftwareBrothers / adminjs

AdminJS is an admin panel for apps written in node.js
https://adminjs.co
MIT License
8.15k stars 659 forks source link

fix: make back button navigate one route up #1545

Closed dziraf closed 1 year ago

dziraf commented 1 year ago

This fixes the issue where drawer doesn't close correctly, but introduces another issue where refreshing the page will result in 404. This is because to=".." relative="path" only removes URL's pathname up to last / which in case of show action removes record's ID which results in drawer getting closed. AdminJS doesn't have a record route without :recordId param defined though, so when you refresh the page you see a CANNOT GET ... error.

We'd probably have to rewrite routing so that routes are nested, this way we could simply use relative="route".

vinu commented 1 year ago

Hmm but will this work? with filters?

I just tried like this

<StyledLink
      size="icon"
      onClick={() => navigate(-1)}
      rounded
      mr="lg"
      type="button"
    >

Seems working

vinu commented 1 year ago

nah - disregard that - it won't work with multiple show click, - the back click just loads the previous show action

dziraf commented 1 year ago

I rewrote routing so that back button works as expected now, but it turned out we also have to rewrite the Drawer component since it doesn't show list underneath anymore.

https://github.com/SoftwareBrothers/adminjs/assets/16668924/d8e1b0cd-a044-4934-8c6a-c771c9de44f5

dziraf commented 1 year ago

It looks to be working correctly now (also fixed a bug where filters weren't retained when opening the drawer)

https://github.com/SoftwareBrothers/adminjs/assets/16668924/63b9ceda-58d3-41b4-9d36-4ff67c5d1024

dziraf commented 1 year ago

fixes https://github.com/SoftwareBrothers/adminjs/issues/1543

github-actions[bot] commented 1 year ago

:tada: This PR is included in version 7.2.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: