Skip to content

Fix: properly merged schema during mergeSchemas part in getBlockContentSchemaFromTransforms #70615

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

Open
wants to merge 6 commits into
base: trunk
Choose a base branch
from

Conversation

USERSATOSHI
Copy link
Contributor

@USERSATOSHI USERSATOSHI commented Jul 4, 2025

What?

Closes #70612

This PR fixes the bug where merging schemas causes top level classes property to convert from array to object with indices as keys.

Why?

As the classes gets converted to Object the cleanNodeList function fails when it tries to map the classes property.
Error at this line

How?

The Solution checks whether b[key] is an array or not, if it is an array , set a[key] to be copy of b[key] else the original object shallow clone.

Testing Instructions

Follow the instructions of #70612

Screenshots or screencast

Before

Screen.Recording.2025-07-04.at.2.08.59.PM.mov

Results

Screen.Recording.2025-07-04.at.2.35.36.PM.mov

Block Transform Code

Screen.Recording.2025-07-04.at.2.37.14.PM.mov

@USERSATOSHI USERSATOSHI marked this pull request as draft July 4, 2025 09:10
Copy link

github-actions bot commented Jul 4, 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: USERSATOSHI <[email protected]>
Co-authored-by: desrosj <[email protected]>
Co-authored-by: getdave <[email protected]>

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

@USERSATOSHI USERSATOSHI marked this pull request as ready for review July 4, 2025 09:45
@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Package] Blocks /packages/blocks labels Jul 4, 2025
@USERSATOSHI
Copy link
Contributor Author

USERSATOSHI commented Jul 23, 2025

oh god, I messed up while trying to merge trunk, sorry.

@USERSATOSHI USERSATOSHI force-pushed the fix/mergeschema-array-to-object branch from e0ea486 to bf62d34 Compare July 23, 2025 21:48
@USERSATOSHI
Copy link
Contributor Author

USERSATOSHI commented Jul 23, 2025

Hi, Sorry to all the reviewers that got the notifications from this PR. I was trying to merge the trunk to update the branch to latest commit but accidentally rebased it.

I have fixed the branch but sorry for the ping that got requested due to this mishap.
I will try to be more mindly-aware of what I am doing from next time.

Sorry again for all this.
Regards

@desrosj
Copy link
Member

desrosj commented Jul 23, 2025

@USERSATOSHI Don't worry about it! We've all been there! 😅 It happens occasionally and is not a big deal.

@USERSATOSHI
Copy link
Contributor Author

😅

@SirLouen SirLouen added Needs Testing Needs further testing to be confirmed. Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code labels Jul 30, 2025
@getdave
Copy link
Contributor

getdave commented Jul 31, 2025

@USERSATOSHI Thanks for the PR. Would it be possible for you to write some tests to replicate the bug you were experiencing and show that your changes resolve this issue 🙏

@USERSATOSHI
Copy link
Contributor Author

USERSATOSHI commented Jul 31, 2025

Thanks for the PR. Would it be possible for you to write some tests to replicate the bug you were experiencing and show that your changes resolve this issue 🙏

Hi @getdave, Just to confirm, I need to write an unit test which would validate the working of the patch, or

a reproduction report and a patch testing report showing the bug replication and patch testing?

If it is the latter , for bug replicate there is a failing action of this
https://github.com/WordPress/gutenberg/actions/runs/16409380285/job/46361037826?pr=70635#step:6:1045

Which should validate that bug replication.

And for patch testing report , I can write the report. 😄

@getdave
Copy link
Contributor

getdave commented Jul 31, 2025

I was thinking of adding some coverage to the existing unit tests in packages/blocks/src/api/raw-handling/test/utils.js.

@USERSATOSHI
Copy link
Contributor Author

I was thinking of adding some coverage to the existing unit tests in packages/blocks/src/api/raw-handling/test/utils.js.

oh got it, I will add the tests for this then. thank you

@USERSATOSHI
Copy link
Contributor Author

USERSATOSHI commented Jul 31, 2025

Hi @getdave, I added tests for coverage of this issue.

Before After

Copy link
Contributor

@Adi-ty Adi-ty left a comment

Choose a reason for hiding this comment

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

LGTM🚀

The Patch fixes the issue I am no longer getting the error.

Bug Reproduction link for anyone to check: #70612 (comment)

Before

image

After

Screenshot 2025-07-31 at 9 02 38 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Review A PR that's suitable for someone looking to contribute for the first time by reviewing code Needs Testing Needs further testing to be confirmed. [Package] Blocks /packages/blocks [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] classes property in transforms breaks if it is not defined in the first block schema
6 participants