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

Add text to image button is shown even when the cover block cannot be inserted #32520

Closed
tomjn opened this issue Jun 8, 2021 · 7 comments · Fixed by #33095
Closed

Add text to image button is shown even when the cover block cannot be inserted #32520

tomjn opened this issue Jun 8, 2021 · 7 comments · Fixed by #33095
Labels
[Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended

Comments

@tomjn
Copy link
Contributor

tomjn commented Jun 8, 2021

Description

There is a transform on the image block that has been turned into a button so that there is an easy shortcut. This button is shown when the cover block is registered.

However, if the cover block settings are filtered so that support for insertion and transforms are removed, the button persists, resulting in broken things ( this site does not support the cover block in these contexts ).

I can find no other solution for removing this ability other that to complete unregister the cover block which is not an option. Users should not be able to insert cover blocks in this context yet this button makes this possible because the supports section is ignored.

WordPress information

  • WordPress version: 5.7+

Device information

  • Device: Desktop
  • Operating system: MacOS 11
  • Browser: Chrome
@Mamaduka
Copy link
Member

Mamaduka commented Jun 9, 2021

Thanks for reporting this, @tomjn.

Can you share the code for filtering cover block settings?

@Mamaduka Mamaduka added [Block] Image Affects the Image Block [Status] Needs More Info Follow-up required in order to be actionable. labels Jun 9, 2021
@github-actions
Copy link

Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Jun 25, 2021
@Mamaduka
Copy link
Member

Hi, @tomjn

I've updated some checks recently for this transformation button #32666.

@tomjn
Copy link
Contributor Author

tomjn commented Jun 25, 2021

Apologies for not getting back on the code example, I don't have a clean code example, I'd have to extract it, but it can be reproduced by making the cover block not support insertions. We use a filter to turn the true to false if the block isn't in a whitelist, likewise we disable the transforms so that images can't be transformed into cover blocks ( we remove it from the block definition ), but this button bypasses that

@tomjn
Copy link
Contributor Author

tomjn commented Jun 25, 2021

TLDR: the button transforms an image block into a cover block, even when that transformation is removed, and when cover blocks supports section is modified by filters so that it cannot be inserted. The only way to remove the button at the moment is to completely unregister the cover block

The change in #32666 may help mitigate this though

@Mamaduka Mamaduka removed [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. labels Jun 25, 2021
@Mamaduka
Copy link
Member

Thanks for the feedback, @tomjn.

We probably need canTransformToBlock or a similar method that handles various checks for the block. I think this is similar to what @mtias suggested here - #32666 (comment).

@Mamaduka
Copy link
Member

Mamaduka commented Jul 1, 2021

Hi, @tomjn

Created second PR that should probably cover all cases - #33095.

@Mamaduka Mamaduka added the [Type] Bug An existing feature does not function as intended label Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants