Skip to content
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: pattern rendering issue #66022

Merged
merged 2 commits into from
Oct 11, 2024
Merged

Conversation

dhruvang21
Copy link
Contributor

@dhruvang21 dhruvang21 commented Oct 10, 2024

What?

part of #66009

Why?

Fixes:- #66009

How?

I’ve tracked down the issue and identified that it occurs because the page is not reset to page 1 when switching tabs. This happens due to the condition failure in the file index.js#L124. When switching tabs between wp_block post type and wp_template_part, neither has a category, so the categoryId defaults to PATTERN_DEFAULT_CATEGORY. As a result, both the previous and current categories are the same, causing the condition to fail. I have added a condition using the same logic for the post type, which resolves the issue

Testing Instructions

  1. Log into your test site.
  2. Go to Appearance > Editor
  3. In the Design menu, select Patterns. By default, the template parts have 5 templates showing
  4. In the "View options", set the Layout to Grid.
  5. Go into all patterns.
  6. Navigate the next page using the pagination at the bottom of the editor.
  7. Select the all template parts tab
  8. Patterns should render after switching to All template parts tab.

Screenshots or screencast

fix-66009.mp4

Copy link

github-actions bot commented Oct 10, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvang21 <dhruvang21@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@talldan talldan added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond labels Oct 10, 2024
@talldan talldan added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 10, 2024
Copy link
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the bug occurs regardless of view type (grid, table). So long as you paginate from all patterns and then switch to the templates view, it'll be empty.

This PR fixes all that. Thank you very much, @dhruvang21!

Before

2024-10-11.13.53.14.mp4

After

2024-10-11.13.53.36.mp4

packages/edit-site/src/components/page-patterns/index.js Outdated Show resolved Hide resolved
packages/edit-site/src/components/page-patterns/index.js Outdated Show resolved Hide resolved
packages/edit-site/src/components/page-patterns/index.js Outdated Show resolved Hide resolved
@ramonjd ramonjd enabled auto-merge (squash) October 11, 2024 03:01
@ramonjd
Copy link
Member

ramonjd commented Oct 11, 2024

I updated the variable name to camelCase and marked this PR to auto-merge.

Great work @dhruvang21 !

@ramonjd ramonjd merged commit e89e988 into WordPress:trunk Oct 11, 2024
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.5 milestone Oct 11, 2024
@github-actions github-actions bot removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 11, 2024
gutenbergplugin pushed a commit that referenced this pull request Oct 11, 2024
When navigating between the "All Patterns" tab (specifically on page 2) and the "Template Parts" tab, the patterns fail to load correctly, and a "No Results" message is displayed. This commit checks for a previous post type, and, if different, resets the pagination to page 1 to ensure the first page of new post types are shown.

---------

Co-authored-by: dhruvang21 <dhruvang21@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Copy link

I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 6b5994a

@github-actions github-actions bot added the Backported to WP Core Pull request that has been successfully merged into WP Core label Oct 11, 2024
ciampo pushed a commit that referenced this pull request Oct 14, 2024
When navigating between the "All Patterns" tab (specifically on page 2) and the "Template Parts" tab, the patterns fail to load correctly, and a "No Results" message is displayed. This commit checks for a previous post type, and, if different, resets the pagination to page 1 to ensure the first page of new post types are shown.

---------

Co-authored-by: dhruvang21 <dhruvang21@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
When navigating between the "All Patterns" tab (specifically on page 2) and the "Template Parts" tab, the patterns fail to load correctly, and a "No Results" message is displayed. This commit checks for a previous post type, and, if different, resets the pagination to page 1 to ensure the first page of new post types are shown.

---------

Co-authored-by: dhruvang21 <dhruvang21@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: talldan <talldanwp@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported to WP Core Pull request that has been successfully merged into WP Core [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Patterns fail to load after switching from all patterns (page 2) to template parts tab
3 participants