-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Improve lists URL management #11022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Improve lists URL management #11022
Conversation
| ) { | ||
| return; | ||
| } | ||
| navigate({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised that this doesn't add a new entry in the history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it does, fix incoming
|
Why are all the packages.json updated? |
Probably my editor, reverting |
ccd5b2b to
22a9fab
Compare
22a9fab to
f545c8d
Compare
| // or the stored params are different from the location params | ||
| isEqual(query, queryFromLocation) || | ||
| // or the stored params are not different from the default params (to keep the URL simple when possible) | ||
| isEqual(query, defaultParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments are describing the opposite condition as the code, so they're confusing.
| // or the stored params are different from the location params | |
| isEqual(query, queryFromLocation) || | |
| // or the stored params are not different from the default params (to keep the URL simple when possible) | |
| isEqual(query, defaultParams) | |
| // or the stored params are the same as the location params | |
| isEqual(query, queryFromLocation) || | |
| // or the stored params are the same as the default params (to keep the URL simple when possible) | |
| isEqual(query, defaultParams) |
| } | ||
| ); | ||
| }, | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you remove this, the linter asks for 2 missing dependencies: queryFromLocation and storeKey. It seems legit to run this effect when these params change. Why did you choose to ignore them?
| }); | ||
| }); | ||
|
|
||
| it('should not synchronize location with store if the store parameters are the defaults', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test with default params set by Component? Something like <Component perPage={5} sort={{ field: 'title', order: 'DESC' }} /> and then check that if the store contains the same values, the location will still be the default with no search param?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added below
| }} | ||
| > | ||
| <CoreAdminContext dataProvider={testDataProvider()}> | ||
| <Component disableSyncWithLocation /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should remove the disableSyncWithLocation otherwise you're not testing the right thing.
| }, | ||
| })} | ||
| > | ||
| <Component disableSyncWithLocation /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove disableSyncWithLocation here
Problem
When users are redirected to a list page for which they previously applied some parameters (page, perPage, filters, etc.), they don't see those parameters reflected in the URL even though they are indeed applied on the list. This happens for instance when redirected from an edition page. This makes the URL non shareable anymore and can be surprising.
Fixes #11018
Solution
When the list loads, if there are stored parameters and those are not reflected in the URL, update the URL except if:
disableSyncLocationistrue/posts)How To Test
make runPerformances
nextbranch, repeat the steps above but enable the react profiler (devtool) before clicking Save at step 3. Note the number of renders of theListcomponentAdditional Checks
masterfor a bugfix or a documentation fix, ornextfor a featureAlso, please make sure to read the contributing guidelines.