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

Extraneous transforms on synced patterns #67710

Open
richtabor opened this issue Dec 7, 2024 · 10 comments
Open

Extraneous transforms on synced patterns #67710

richtabor opened this issue Dec 7, 2024 · 10 comments
Labels
[Feature] Block Transforms Block transforms from one block to another [Type] Bug An existing feature does not function as intended

Comments

@richtabor
Copy link
Member

Description:

Transforms for synced patterns are overly generous, even if transforms simply wrap content. This behavior can create confusion and lead to unintended transformations. Limiting transforms from synced patterns would provide a more intuitive experience.

Steps to Reproduce:

  1. Insert a synced pattern.
  2. Attempt to transform the pattern.
  3. Observe the availability of excessive transform options.

Expected:

Transform options should be limited for synced patterns to avoid unnecessary or unintended transformations.

Visual

Image

@richtabor richtabor added [Feature] Block Transforms Block transforms from one block to another [Type] Bug An existing feature does not function as intended labels Dec 7, 2024
@Mamaduka
Copy link
Member

Mamaduka commented Dec 8, 2024

What's your proposal?

@Rishit30G
Copy link
Contributor

Hi
I'm able to understand the issue, however I'm curious to know where will these changes specifically take place in code
I'm sharing the files that I looked up for making changes:

packages/block-editor/src/components/block-toolbar/index.js
packages/block-editor/src/components/block-switcher/index.js

Would appreciate some help on this one
Thanks 🙇🏻

@Mamaduka
Copy link
Member

Mamaduka commented Dec 9, 2024

@Rishit30G, it depends on the proposed solution, which needs clarification. Do we disable transformations for synced patterns or just reduce the options? If the latter, then what options should remain?

@Rishit30G
Copy link
Contributor

Thanks for addressing @Mamaduka , I was planning to limit the options once we get confirmation on which ones to keep
So meanwhile I was trying to find ways to limit the options, but the thing was that I wasn't able to find where the options are coming from

@Mamaduka
Copy link
Member

Mamaduka commented Dec 9, 2024

@Rishit30G, have look at packages/block-editor/src/components/block-switcher/index.js file. It is responsible for rendering transformations.

@Rishit30G
Copy link
Contributor

Thanks, I explored couple of helper functions in this order from selector.js and factory.js:
getPossibleBlockTransformations() -> getBlockTypesForPossibleFromTransforms() -> isPossibleTransformForSource()
But I only came to a conclusion that any changes made to them can globally affect the other transformation, curious to know how can we isolate changes specific to template transformations

@talldan
Copy link
Contributor

talldan commented Dec 11, 2024

Easiest thing might be to add an isMatch property to the transform definitions to exclude the 'core/block'.

The details block already has similar to prevent wrapping itself in another details block:

isMatch( {}, blocks ) {
return ! (
blocks.length === 1 && blocks[ 0 ].name === 'core/details'
);
},

@talldan
Copy link
Contributor

talldan commented Dec 18, 2024

@Rishit30G Is this something you're still interested in working on?

@Rishit30G
Copy link
Contributor

Hi @talldan
Yes, I would still be interested to work on it, sorry for the delayed response 🙇🏻
Incase I'm not able to by today, I would pass it back
Thanks

@Rishit30G
Copy link
Contributor

Rishit30G commented Dec 18, 2024

Thanks for sharing insights @talldan 🙇🏻
I have tried implementing it, please check the screencast below:
https://github.com/user-attachments/assets/75ca4f73-bd5b-4e51-984e-edfaae932c70
So for now, I have tried to removing the details block from the core/block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Transforms Block transforms from one block to another [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants