Skip to content

Popover Component: correct changing positions #19992

Merged
AnnaMag merged 1 commit intomasterfrom
fix/jetpack-popup
Nov 20, 2017
Merged

Popover Component: correct changing positions #19992
AnnaMag merged 1 commit intomasterfrom
fix/jetpack-popup

Conversation

@AnnaMag
Copy link
Copy Markdown
Contributor

@AnnaMag AnnaMag commented Nov 18, 2017

Fixes #19666

This patch wraps a function which updates Popover DOM container in componentDidUpdate lifecycle method in a setTimeout callback, so that we read off positioning after it finished rendering.

To test:
I believe the issue persists across different sections and settings, mobile or not, so please test on any popover occurrence in Calypso. In particular, we should not see #19666 on the Plans page https://wordpress.com/plans/:site.

  • opening, closing and re-opening should not move the component outside of the page view ( or anywhere else :) )
  • it should work when changing screen size

Note:
works for other issues where popovers were wrongly positioned
#9007
#13602
#14580

This does not fix the vertical scroll problem, where popovers move into top/bottom margins following their context ( IMO it is a CSS fix and is a separate issue ): #20014

@AnnaMag AnnaMag self-assigned this Nov 18, 2017
@matticbot
Copy link
Copy Markdown
Contributor

@AnnaMag AnnaMag added Components [Status] In Progress Bug When a feature is broken and / or not performing as intended labels Nov 18, 2017
@AnnaMag AnnaMag requested a review from retrofox November 18, 2017 21:41
@AnnaMag AnnaMag force-pushed the fix/jetpack-popup branch 2 times, most recently from 7534cb1 to 1c8f429 Compare November 19, 2017 23:27
@AnnaMag
Copy link
Copy Markdown
Contributor Author

AnnaMag commented Nov 19, 2017

Thoughts:
IMHO the setPosition() call in the lifecycle method might be obsolete here altogether. Should it stay, I propose to wrap its setState() call in conditional checks (since it is done in a lifecycle method).

@AnnaMag AnnaMag requested a review from tyxla November 19, 2017 23:51
@AnnaMag AnnaMag added [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. and removed [Status] In Progress labels Nov 19, 2017
Copy link
Copy Markdown
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

This resolves the issue for me 👍 Tested on various locations, seems like it does the job 🎉

Left a small comment, but other than that I think we can go with this quick fix for now 👍

Also, let's make sure tests still pass (seems like they timed out the last time)

Comment thread client/components/popover/index.jsx Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This might be shortened to:
setTimeout( () => this.setPosition(), 0 );

`setPosition` function in the `componentDidUpdate` is called
before the popover is finished being drawn. SetTimeout is added
to read of positioning after that is complete.
@AnnaMag
Copy link
Copy Markdown
Contributor Author

AnnaMag commented Nov 20, 2017

Thank you @tyxla for reviewing. Addressed. Let's 🚢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.org Plans: pop-up feature descriptions are misplaced

3 participants