gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Gutenberg Prev Props doesn't get updated

Open MD-sunilprajapati opened this issue 5 years ago • 5 comments

Description

Hello

Here is details about issue:

Consider I have paragraph block with text below ( I have added it as HTML for more clarity ): Contrary to <strong>popular</strong><strong> belief</strong>, Lorem Ipsum is not simply random text

Now, when this block load, Here how it look: Contrary to <strong>popular belief</strong>, Lorem Ipsum is not simply random text

Its combine two strong tag into one. But when we check prevProps, the block attribute content isn't updated in prevProps.

so, is it bug ? or this is how Gutenberg suppose to behave. If so, can I get Gutenberg method where its combine two adjacent similar html tag into one.

Thank you for your help in advance.

Step-by-step reproduction instructions

  1. create paragraph block with some content
  2. Make two adjacent text to bold format
  3. then, this two strong tag will become one tag.
  4. Now if you check block attribute content in prevProps, it contain two different strong tag. Where it should be one strong tag as it have rendered.

Screenshots, screen recording, code snippet

No response

Environment info

  • WordPress version 5.8.1
  • Chrome browser
  • Desktop with window 10

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

MD-sunilprajapati avatar Sep 13 '21 08:09 MD-sunilprajapati

In Gutenberg, preProps are the past image of the current version of that element or the attribute. So, yes it is supposed to behave that way. It's not a bug.

HILAYTRIVEDI avatar Sep 14 '21 11:09 HILAYTRIVEDI

My understanding is that two adjacent tags like that will be merged, it's the expected behavior.

What's the use-case for having two separate tags?

talldan avatar Sep 20 '21 05:09 talldan

yes, it expected behaviour, but it should be also merge in prevPros attribute content. right now, it get merged on render, but if we check same block content in prevProps, it saparated.

MD-sunilprajapati avatar Sep 20 '21 07:09 MD-sunilprajapati

@talldan we are developing one tool which used to identify changes that have been made to block. sometimes users add a bold format on a text which will be in the new STRONG tag, even if an adjacent text has a bold format, and we use block PrevProps to find out the changes.

so what exactly happen is ::

When we add bold format on "brlief" text below:: Contrary to <strong>popular</strong>belief

editor will have this:: Contrary to <strong>popular belief</strong>

But when we check PrevProps value in block, it have this :: Contrary to <strong>popular</strong><strong> belief</strong>

where the editor value and PrevProps value should be the same.

MD-sunilprajapati avatar Apr 16 '22 08:04 MD-sunilprajapati

Closing as working as intended: adjacent identical format tags are normalized/merged when the value is rendered — that's rich-text canonicalization, and comparing against pre-normalization props will always show that difference. No changes planned here; if this causes a concrete bug in a block, a report with that repro would be actionable.

youknowriad avatar Sep 04 '26 08:09 youknowriad