Skip to content

Prevent block invalidation due to missing width/height#2557

Merged
swissspidy merged 8 commits intodevelopfrom
fix/block-style-invalidation
Jun 11, 2019
Merged

Prevent block invalidation due to missing width/height#2557
swissspidy merged 8 commits intodevelopfrom
fix/block-style-invalidation

Conversation

@swissspidy
Copy link
Copy Markdown
Collaborator

Fixes #2556

@googlebot googlebot added the cla: yes Signed the Google CLA label Jun 11, 2019
@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

I'm still seeing a validation error after resizing a Text block and then reloading the page:

Screen Shot 2019-06-11 at 11 00 50 AM

@swissspidy
Copy link
Copy Markdown
Collaborator Author

swissspidy commented Jun 11, 2019

Looks like the onResizeStop() call in ResizableBox tries to get the position from the wrong element, so positionTop is something like calc(10% - 5px) and positionLeft is something like calc(5% - 5px).

Edit: these calc() values come from withWrapperProps

@swissspidy swissspidy changed the title Prevent block invalidation due to missing width/height [WIP] Prevent block invalidation due to missing width/height Jun 11, 2019
@swissspidy
Copy link
Copy Markdown
Collaborator Author

@kienstra since this whole position adjustment for text blocks is something you have implemented, you are probably better suited for looking at this.

@kienstra
Copy link
Copy Markdown
Contributor

Sure, I'll work on this, though I'm not sure if I'll be able to fix it 😄

@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

I can take a look as well.

…ming null

It looks like on resizing,
these attributes become null.
@googlebot
Copy link
Copy Markdown

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no Has not signed the Google CLA and removed cla: yes Signed the Google CLA labels Jun 11, 2019
@miina miina changed the title [WIP] Prevent block invalidation due to missing width/height Prevent block invalidation due to missing width/height Jun 11, 2019
@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

@swissspidy Could you test if it works OK now?

@swissspidy
Copy link
Copy Markdown
Collaborator Author

@miina If I position a block somewhere, and then increase its height like 20 times, it moves a bit to the the top every time. Demo: https://cloudup.com/c_kA2ebgcre

@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

@swissspidy That should be fixed within 544d2c8 now.

Found another issue though that's occurring now -- when the block is rotated it's quite "jumpy" when resizing. It looks like the reason is using integers for top and left positioning and ignoring the decimals. We should probably rework this to use decimals as we're doing for the width and height already.

Not sure if it's better to do it within this PR or separately. Perhaps separately since it's not necessarily a blocker for RC. Thoughts?

@swissspidy
Copy link
Copy Markdown
Collaborator Author

@miina You added some Math.round() calls there - are these the reason? If so, are they needed?

@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

You added some Math.round() calls there - are these the reason? If so, are they needed?

I added the Math.round calls since the top and left attributes were saved without decimals. Since the resizing itself was using the decimals then the difference between the saved value and the displayed value was causing the position to shift when resizing (even without rotation). Now the displayed position reflects the saved value accurately and doesn't jump anymore when resizing. However, having an angle requires the top and left also to be changed during resizing and now it's more "jumpy" since the displayed value isn't using decimals anymore.

I will look more into the jumpiness issue, not sure how much time it'll take. Hopefully, it'll be quite straightforward. If it's OK not to merge this fix yet for the Text block then I'll just continue within this PR.

@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

Alright, rounding is removed now. Would you mind testing again, @swissspidy?

Copy link
Copy Markdown
Collaborator Author

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

Seems to work well now.

Left a comment about the position block attributes.

Cannot approve my own PR, so someone else would have to do that :)

@miina
Copy link
Copy Markdown
Contributor

miina commented Jun 11, 2019

Left a comment about the position block attributes.

Just approved the PR, if removing the type from position attributes is OK for you then let's merge.

Copy link
Copy Markdown
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

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

Approved

Hi @miina and @swissspidy,
Thanks a lot for fixing this.

Now, resizing the text block doesn't cause a validation error. Dragging also works well:

text-block-works

@swissspidy swissspidy added cla: yes Signed the Google CLA and removed cla: no Has not signed the Google CLA labels Jun 11, 2019
@googlebot
Copy link
Copy Markdown

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@swissspidy swissspidy merged commit 066eef8 into develop Jun 11, 2019
@swissspidy swissspidy deleted the fix/block-style-invalidation branch June 11, 2019 17:28
westonruter added a commit that referenced this pull request Jun 11, 2019
…ide-lighter-media

* 'develop' of github.com:ampproject/amp-wp:
  Fix resizing for formatting blocks (#2562)
  Prevent block invalidation due to missing width/height (#2557)
@westonruter westonruter added this to the v1.2 milestone Jun 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Signed the Google CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resizing text block causes validation error

5 participants