Amp-wp: Wrapper elements causes problem for conversion in Block Resolving for Stories

Created on 21 May 2019  ·  8Comments  ·  Source: ampproject/amp-wp

I made a story page as depicted in #2368 and then when I tried switching to the branch, I got the expected:

image

When clicking “Resolve” the suggested resolution is not correct:

Screen Shot 2019-05-21 at 13 47 20

The amp-story-grid-layer and the amp-story-block-wrapper are incorrectly getting added a second time.

Fixing this will be very important once stories are in a stable release, in addition to making sure that we start maintaining deprecated conversions.

AMP Stories (obsolete) Bug

All 8 comments

Note: Also reported in #2376.

I cannot reproduce this with the steps outlined in #2376, which would have been a more likely scenario than switching branches.

However, given that theses divs are added by wrapBlocksInGridLayer, I wonder if that function could simply check element to see whether these divs already exist.

Also, since this function is hooked to blocks.getSaveElement, maybe this is a bug in Gutenberg. https://github.com/WordPress/gutenberg/issues/9811 looks relevant here.

@swissspidy Here's a quick way to easily reproduce this:

  1. Start npm run dev
  2. Start a story with a single text block.
  3. Save draft.
  4. Make a change to the output of the block's save function, for example:
diff --git a/assets/src/stories-editor/blocks/amp-story-text/save.js b/assets/src/stories-editor/blocks/amp-story-text/save.js
index b74a1ccd..afc57b99 100644
--- a/assets/src/stories-editor/blocks/amp-story-text/save.js
+++ b/assets/src/stories-editor/blocks/amp-story-text/save.js
@@ -45,7 +45,7 @@ const TextBlockSave = ( { attributes } ) => {
        <ContentTag
            style={ styles }
            className={ className }>
-           <amp-fit-text layout="flex-item" className="amp-text-content"><RawHTML>{ content }</RawHTML></amp-fit-text>
+           <amp-fit-text layout="flex-item" className="amp-fitted-text-content"><RawHTML>{ content }</RawHTML></amp-fit-text>
        </ContentTag>
    );
 };
  1. Reload the editor and voilà:

image

image

@westonruter That‘s not really common, is it? When we change the markup in the future we‘d properly deprecate the old one.

Well, it _has_ happened very frequently. I _hope_ it wouldn't happen after we release, but there should still be graceful handling if it does happen (e.g. if someone tries editing the HTML directly).

Created a PR at #2484 that should theoretically fix this.

Technical QA?

Hi @swissspidy,
Do you think the 'technical QA' as part of your #2484 is enough to move this to 'Ready for merging?' Or do you think more functional testing would help?

I think we're good here!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

swissspidy picture swissspidy  ·  5Comments

GitaStreet picture GitaStreet  ·  4Comments

fumikito picture fumikito  ·  5Comments

luizeof picture luizeof  ·  4Comments

westonruter picture westonruter  ·  3Comments