Skip to content

fix: insertion of prompts around Group blocks#855

Merged
dkoo merged 2 commits intomasterfrom
fix/group-block-insertion
Apr 20, 2022
Merged

fix: insertion of prompts around Group blocks#855
dkoo merged 2 commits intomasterfrom
fix/group-block-insertion

Conversation

@dkoo
Copy link
Contributor

@dkoo dkoo commented Apr 19, 2022

All Submissions:

Changes proposed in this Pull Request:

Fixes the insertion algorithm of inline blocks around Group blocks. Previously the length of the Group's inner blocks wasn't factored into the total article length calculation, so inline prompts wouldn't get properly inserted into posts consisting mostly of multiple Groups.

How to test the changes in this Pull Request:

  1. Create a post consisting of several top-level Group blocks. Or copy the following test content:
Expand to copy
<!-- wp:paragraph -->
<p>Nam tellus duis magna finibus penatibus eleifend maecenas aptent, senectus quam egestas dictum dapibus eu risus maximus, ligula lacus cras malesuada ipsum montes bibendum. Donec hendrerit aenean in pharetra suspendisse conubia ligula sollicitudin quis placerat varius sodales, natoque mattis mollis per ad dapibus taciti ut platea tempor. Aenean integer duis consectetur nam dignissim nullam leo semper, viverra venenatis placerat convallis scelerisque lectus.</p>
<!-- /wp:paragraph -->

<!-- wp:group -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>Fermentum sed condimentum magnis habitant mi penatibus platea ridiculus mus maecenas est magna, pharetra elementum sem non vivamus diam lacus egestas nascetur felis. Vehicula lectus condimentum curabitur quam semper est sollicitudin, parturient rutrum id</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p> vivamus dis per. Viverra porta sit hendrerit vivamus dapibus pellentesque dictumst duis, et interdum pulvinar sed maximus senectus convallis etiam, vitae sem sollicitudin augue imperdiet quis arcu. Inceptos ridiculus felis dignissim ullamcorper massa porta semper facilisi consectetur duis eros, ultrices placerat nisi velit urna nascetur est dis ipsum penat</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>ibus. Velit erat ligula quisque aliquam pulvinar dignissim luctus vel commodo sagittis bibendum scelerisque sem a enim, senectus parturient litora ornare aenean imperdiet ipsum sed ridiculus lorem dictumst pellentesque sapien.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:group -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>A mauris pellentesque eros accumsan dui fusce scelerisque litora nam efficitur massa tempor vestibulum, ex sagittis cubilia ullamcorper dis maximus leo conse</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>ctetur potenti quam finibus. Quisque commodo phasellus suscipit molestie proin rutrum fringilla id congue mus tempor class primis, mattis maximus hendrerit tellus duis vestibulum sed in platea natoque vitae. At ante sagittis parturient conubia posuere ullamcorper maecenas fringilla finibus erat quisque aliquet, pulvinar gravida facilisi interdum praesent est commodo molestie v</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>itae semper sociosqu. Nulla potenti risus quam tempus est litora vitae duis class tellus cursus tortor condimentum, euismod sodales dapibus etiam integer in phasellus scelerisque lectus nunc erat.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:group -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>Lectus molestie a rutrum montes scelerisque lacus praesent id sociosqu aliquam, hac quisque taciti vehicula mi erat ligula magnis est. Porttitor sem leo hendrerit condimentum metus ridiculus class efficitur praesent faucibus cursus, a ultrices rutrum egestas lacus ligula blandit elementum malesuada dictum.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:group -->
<div class="wp-block-group"><!-- wp:paragraph -->
<p>Purus dictumst vulputate quam mauris integer aenean mattis maximus finibus pretium neque eleifend, lacus lorem hac lectus velit egestas porttitor venenatis nunc eros enim. Dapibus fringilla sodales libero aptent ornare pulvinar curabitur maximus est pretiu</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>m aliquam dolor litora blandit suspendisse, per nascetur egestas pellentesque tellus massa condimentum interdum lectus parturient hac magnis diam consectetur. Efficitur pharetra tempor ipsum maximus rhoncus primis dui, ultricies feugiat volutpat vitae vivamus. Egestas tristique enim gravida tellus finibus neque suspendisse sagittis eu dolor mollis, molestie fringilla purus aptent mauris senectus commodo parturient ex vivamus.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->
  1. Publish an inline prompt and set the insertion logic to "Percentage" at 50%.
  2. On master, view on the front-end and observe that the prompt gets inserted at the very end of the article.
  3. Check out this branch, refresh, and confirm that the prompt gets inserted at roughly 50% of the content, as expected.
  4. Test with various percentages and Block Count criteria to confirm that nothing else looks off.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@dkoo dkoo added bug Something isn't working [Status] Needs Review labels Apr 19, 2022
@dkoo dkoo requested a review from a team as a code owner April 19, 2022 21:52
@dkoo dkoo self-assigned this Apr 19, 2022
Copy link
Member

@miguelpeixe miguelpeixe left a comment

Choose a reason for hiding this comment

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

Using the recursive innerBlocks strategy from get_block_content() fixes the issue! 🙌

@dkoo dkoo merged commit 6ae5ea9 into master Apr 20, 2022
@dkoo dkoo deleted the fix/group-block-insertion branch April 20, 2022 15:56
matticbot pushed a commit that referenced this pull request Apr 20, 2022
# [1.52.0-alpha.1](v1.51.1-alpha.1...v1.52.0-alpha.1) (2022-04-20)

### Bug Fixes

* insertion of prompts around Group blocks ([#855](#855)) ([6ae5ea9](6ae5ea9))

### Features

* support other newsletter signup forms ([#836](#836)) ([c30702d](c30702d))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.52.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Apr 20, 2022
# [1.52.0](v1.51.0...v1.52.0) (2022-04-20)

### Bug Fixes

* insertion of prompts around Group blocks ([#855](#855)) ([6ae5ea9](6ae5ea9))
* make "scroll" the default inline trigger_type ([#846](#846)) ([a2ffee4](a2ffee4))

### Features

* support other newsletter signup forms ([#836](#836)) ([c30702d](c30702d))
@matticbot
Copy link
Contributor

🎉 This PR is included in version 1.52.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

dkoo added a commit that referenced this pull request Apr 20, 2022
matticbot pushed a commit that referenced this pull request Apr 20, 2022
## [1.52.1-hotfix.1](v1.52.0...v1.52.1-hotfix.1) (2022-04-20)

### Reverts

* Revert "fix: insertion of prompts around Group blocks (#855)" ([b9917f2](b9917f2)), closes [#855](#855)
@dkoo dkoo mentioned this pull request Apr 20, 2022
6 tasks
dkoo added a commit that referenced this pull request Apr 20, 2022
* Revert "fix: insertion of prompts around Group blocks (#855)"

This reverts commit 6ae5ea9.
matticbot pushed a commit that referenced this pull request Apr 20, 2022
## [1.52.1](v1.52.0...v1.52.1) (2022-04-20)

### Bug Fixes

* revert group insertion fix ([#858](#858)) ([15af041](15af041)), closes [#855](#855)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants