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

"Multiple use" block validation logic improvement. #40901

Conversation

delowardev
Copy link
Contributor

What?

Fixes: #38502

Why?

Any block that doesn't support the multiple feature, doesn't display the Multiple blocks validation warning when it's inside group blocks.

How?

Include innerBlocks in the validation process.

Testing Instructions

  1. Open post or page to edit
  2. Insert "Group" block
  3. Insert the "More (core/more)" block inside the "Group" block
  4. Duplicate "Group" block.

The "Read more" should display the validation warning.

Screenshots or screencast

Before:

before.mov

After:

after.mov

@delowardev
Copy link
Contributor Author

delowardev commented May 6, 2022

@getdave Thanks for your feedback on the previous PR. ( My local git history got messed up somehow, So I had to close that PR )

I tried with the core/read-more block and it seems to support multiple. I wonder if that's a mistake?

Could you please try with core/more block; it doesn't support multiple

Using within a Query Loop in the Site Editor, if I duplicate the loop then the editor shows an error. Presumably, it's valid to use the More block twice when it's part of a template so we're going to have to make the validation logic more flexible.

I think core/more is not supposed to be used in the query loop/post-template; instead, it should be used in the post content.

e2e Test has been added.

@skorasaurus skorasaurus added the [Package] Edit Post /packages/edit-post label Dec 25, 2023
Copy link

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Type-related labels to choose from: [Type] Automated Testing, [Type] Breaking Change, [Type] Bug, [Type] Build Tooling, [Type] Code Quality, [Type] Copy, [Type] Developer Documentation, [Type] Enhancement, [Type] Experimental, [Type] Feature, [Type] New API, [Type] Task, [Type] Performance, [Type] Project Management, [Type] Regression, [Type] Security, [Type] WP Core Ticket, Backport from WordPress Core.
  • Labels found: [Package] Edit Post.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

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

Thanks for this PR. It looks like a good enhancement 👍

Do you think you'll be able to move the tests to use Playwright as we now only use that tool to write new tests?

If you're struggling for time please let us know.

Thanks again

*/
import { createNewPost, insertBlock } from '@wordpress/e2e-test-utils';

describe( 'Validate multiple use', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move this test to use Playwright?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @getdave, thanks for your review. I'm away from work for the next few weeks, so It would be nice if anyone were interested in taking this issue.

@getdave
Copy link
Contributor

getdave commented Feb 9, 2024

Shall we close this one in favour of #57576?

@getdave getdave closed this Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Edit Post /packages/edit-post
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid multiple block adding while "multiple" is false in block.json
4 participants