-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix: DataViews: Layout resets for patterns each time a new pattern category is selected. #63711
Fix: DataViews: Layout resets for patterns each time a new pattern category is selected. #63711
Conversation
…tegory is selected.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +5 B (0%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
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.
Confirming this is working.
} | ||
}, [ categoryId, previousCategoryId ] ); | ||
}, [ categoryId, previousCategoryId, view ] ); |
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.
Passing the same state as a dependency as the effect updates could easily lead to infinite loops, especially when this state is an object. Only having a category check prevents that here.
Let's use the state updater function instead - setView( ( prevView ) => ( { ...prevView, page: 1 } ) );
.
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.
Updated in 0383686.
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.
Thanks for the fix 👍
LGTM!
Before | After |
---|---|
Screen.Recording.2024-07-19.at.12.50.53.PM.mp4 |
Screen.Recording.2024-07-19.at.12.50.14.PM.mp4 |
Thank you for helping this PR get merged @Mamaduka, @aaronrobertshaw, and @jameskoster ! |
Does this need to be backported? |
Fixes: #63393
We were forcing the grid layout each time a pattern category was changed, and all the other defaults. This PR fixes the issue by keeping the previous view, and just resetting the page to 1 as the comment there indicated.
Testing Instructions
Go to the patterns page.
Switch to the table layout, change the pattern category, and verify that the table layout is active.