Skip to content

Conversation

@devansh016
Copy link
Contributor

What?

This PR resolves a console error that occurs when interacting with the "Sort by" or "Order by" dropdowns on the Patterns page. A null check for contentDocument has been added to ensure iframe initialization happens only after the iframe content is fully loaded.

Why?

The error prevents the proper functioning of the Patterns page, impacting the user experience. This issue was reproducible across multiple themes and environments, as detailed in the related issue.

Related Issue: #68562

How?

The fix introduces a null check for contentDocument in the iframe initialization logic. This ensures that operations on the iframe are only executed when its content is available, preventing the TypeError that previously occurred.

Introduced in #38855 ( since we no longer try to initialise the iframe before the load event) another reference #51003

Testing Instructions

  1. Go to the Patterns page in the WordPress admin.
  2. Interact with the "Sort by" or "Order by" dropdown to change the sorting order.
  3. Verify that no errors appear in the browser console.
  4. Confirm that the dropdown functionality works as expected.

Screenshots or screencast

Screenshot 2025-01-09 at 5 41 31 PM

…erns page by adding a null check for contentDocument.
@devansh016 devansh016 requested a review from ellatrix as a code owner January 9, 2025 12:18
@github-actions
Copy link

github-actions bot commented Jan 9, 2025

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: devansh016 <[email protected]>
Co-authored-by: carolinan <[email protected]>
Co-authored-by: dhruvang21 <[email protected]>
Co-authored-by: Mayank-Tripathi32 <[email protected]>
Co-authored-by: Gulamdastgir-Momin <[email protected]>

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

@t-hamano t-hamano linked an issue Jan 11, 2025 that may be closed by this pull request
6 tasks
@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Block editor /packages/block-editor labels Jan 11, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Hi @devansh016, thanks for the PR.

As discussed in #68562, we might need to investigate the underlying issue a bit more.

Let's close this PR for now and continue our exploration in #68562.

@t-hamano t-hamano closed this Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Console error when using "Sort by" or "Order by" on the Patterns page

2 participants