Skip to content

Conversation

@youknowriad
Copy link
Contributor

On small screens where the inserter can't show up fully, this PR #11257 introduced a small regression where the popover was recomputing its height constantly causing this weird behavior.

popoverdance

In This PR, I'm updating it to only recompute if the anchor position changes, we can't recompute if the popover size change because the recomputing itself can cause the popover size to change causing an infinite loop.

@youknowriad youknowriad added [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release labels Nov 12, 2018
@youknowriad youknowriad self-assigned this Nov 12, 2018
@youknowriad youknowriad requested review from a team and mmtr November 12, 2018 09:06
@youknowriad youknowriad mentioned this pull request Nov 12, 2018
4 tasks
@youknowriad youknowriad added this to the 4.3 milestone Nov 12, 2018
Copy link
Contributor

@mmtr mmtr left a comment

Choose a reason for hiding this comment

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

It looks good to me. Left a minor note, but I don't consider it a blocker

if ( didPopoverSizeChange ) {
this.setState( { popoverSize } );
}
this.anchorRect = anchorRect;
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we also check here if the anchor moves like we do on refreshOnAnchorMove? And then call to this.computePopoverPosition( popoverSize, anchorRect ); only if didPopoverSizeChange or didAnchorRectChange.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was the first thing I tried but it's not enough because the anchor don't move when we resize the window and we do need to update the popover in this case.

Copy link
Member

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

Tested locally and seems good to me!


// Property used keep track of the previous anchor rect
// used to compute the popover position and size.
this.anchorRect = {};
Copy link
Member

Choose a reason for hiding this comment

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

Can't we just say rectangle? We can spare the bytes 😉

Suggested change
this.anchorRect = {};
this.anchorRectangle = {};

Copy link
Member

Choose a reason for hiding this comment

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

I guess a bunch of the DOM APIs use Rect, so I suppose for consistency it's fine. I just dislike it, but I guess my beef is with JS, not this variable name 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, since this is mainly based on getBoundingClientRect I'd be in favor of keeping "rect" at the moment.

@youknowriad youknowriad merged commit 96df8ee into master Nov 12, 2018
@youknowriad youknowriad deleted the fix/popover-refresh branch November 12, 2018 10:42
youknowriad added a commit that referenced this pull request Nov 12, 2018
* Only refresh the popover if the anchor position changes (#11751)

* Update plugin version to 4.3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants