fix: position calculation for inline popups#1350
Conversation
|
This was already done and reverted in #855. @dkoo, that's a tricky one that I know you've faced before. Publishers tweaked the prompt position until it was visually acceptable no matter the number, changing the logic will impact everyone regardless. I'll keep this as a draft until we figure out how to deal with this. |
dkoo
left a comment
There was a problem hiding this comment.
It's still not perfect, but it's much better. For example, with the following content I'd expect the 50% block to be inserted between the second and third List blocks, but it's actually inserted between the first and second. But I think this is definitely an improvement over what we have, and the accuracy will probably get better with longer content as well.
<!-- wp:list -->
<ul class="wp-block-list"><!-- wp:list-item -->
<li>List item 1</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 1</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 2</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 3</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 4</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 5</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 6</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
<!-- wp:list -->
<ul class="wp-block-list"><!-- wp:list-item -->
<li>List item 1</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 2</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 3</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 4</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 5</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 6</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
<!-- wp:list -->
<ul class="wp-block-list"><!-- wp:list-item -->
<li>List item 1</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 2</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 3</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 4</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 5</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 6</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->
<!-- wp:list -->
<ul class="wp-block-list"><!-- wp:list-item -->
<li>List item 1</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 2</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 3</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 4</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 5</li>
<!-- /wp:list-item -->
<!-- wp:list-item -->
<li>List item 6</li>
<!-- /wp:list-item --></ul>
<!-- /wp:list -->|
Looks like there's a failing test, too—does this indicate a regression in the "single group block + 0% prompt" scenario? |
All Submissions:
Changes proposed in this Pull Request:
https://app.asana.com/0/1200550061930446/1206767149727703/f
The logic used to calculate the position for the inline popups is not the same as applied to determining the position of the blocks.
When doing it for the block positions it's ignoring the HTML for inner blocks, causing blocks like lists to be miscalculated and inline prompts using percentage positioning to appear further down than they should.
This PR introduces a
get_block_lengthmethod to normalize how they are calculated, also fixing the issue with lists.How to test the changes in this Pull Request:
Other information: