Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor PostVisibility to use Popover component #1204

Merged
merged 2 commits into from
Jul 31, 2017

Conversation

aduth
Copy link
Member

@aduth aduth commented Jun 15, 2017

Related: #1193

This pull request seeks to extend generalized Popover behavior from #1193, refactoring PostVisibility to make use of the common component in place of its specific implementation. Refactoring will continue in subsequent pull requests to also revise the PostSchedule component. The changes here required some additional effort to improve Popover to be less specific to the Inserter use-case.

Implementation notes:

The Popover component now renders content within a nested div. The reason for this is to allow the root node to be 0px by 0px, positioned absolutely at the edge relative to the parent in which it is rendered. This ensures that the arrow is always shown exactly at the anchor point, and content is adjusted per the desired direction.

Design Notes:

Some design changes were necessary to better serve general Popover usage. Previously the left-bound inserter in post content had extended further to the left. Attempting to mirror this in the sidebar visibility dialog proved to exceed the page boundaries, so it was brought tighter in line with the node to which the dialog is anchored. Additionally, the editor header inserter Popover no longer opens anchored to the "+" icon but instead centered to the entire "+ Insert" button text.

Testing instructions:

While this pull request is targeted at PostVisibility, due to refactoring of the Popover component, additional testing should be done on the Inserter (small and large viewports) to ensure that no regressions have been introduced.

Repeat testing instructions from #1193.

Verify that the Post Visibility dialog appears and behaves more-or-less identical as it does in the master branch.

Follow-up Tasks:

  • Refactor PostSchedule
  • Move onClickOutside behavior to Popover, accepting an onClose prop handler

@aduth aduth added General Interface Parts of the UI which don't fall neatly under other labels. [Feature] Inserter The main way to insert blocks using the + button in the editing interface Mobile Web Viewport sizes for mobile and tablet devices labels Jun 15, 2017
</div>
{ visibilityOptions.map( ( { value, label, info, onSelect, checked } ) => (
<label key={ value } className="editor-post-visibility__dialog-label">
<span className="editor-post-visibility__button-wrapper">
Copy link
Member Author

Choose a reason for hiding this comment

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

Majority of changes here are simply to wrap the button and Popover in a span to which a position: relative; style is applied, allowing the Popover to position itself within (necessary since div is not a valid child of button).

Using something like react-portal could allow us to be less particular about the DOM structure or relative positioning. Portals are apparently supported in React 16 out-of-the-box, but I am not sure if they are documented yet.

@aduth
Copy link
Member Author

aduth commented Jul 17, 2017

Rebased to resolve conflicts. This would be a good one to move forward on because we're having to deal with many implementation-specific requirements that would be good to consolidate (e.g. click outside, blur, etc).

@jasmussen
Copy link
Contributor

jasmussen commented Jul 26, 2017

Could be due to changes recently happening in master, but I'm seeing a little weirdness with both the inserter and the visibility popover:

screen shot 2017-07-26 at 09 01 39

screen shot 2017-07-26 at 09 01 58

Edit: Again I had to checkout using origin/update/visibility-popover. Don't know why my git is so broken.

@aduth aduth force-pushed the update/visibility-popover branch from dc1caca to 9c459cc Compare July 27, 2017 19:15
@aduth
Copy link
Member Author

aduth commented Jul 27, 2017

@jasmussen I just rebased the branch, and am unable to reproduce. Could you try deleting your local copy and giving it another go? If you're still having trouble, could you let me know which browser / version you're using?

@codecov-io
Copy link

codecov-io commented Jul 27, 2017

Codecov Report

Merging #1204 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1204   +/-   ##
=======================================
  Coverage   20.34%   20.34%           
=======================================
  Files         135      135           
  Lines        4237     4237           
  Branches      722      722           
=======================================
  Hits          862      862           
  Misses       2843     2843           
  Partials      532      532
Impacted Files Coverage Δ
editor/sidebar/post-visibility/index.js 0% <0%> (ø) ⬆️
components/popover/index.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e514290...5a58688. Read the comment docs.

@jasmussen
Copy link
Contributor

I now see no diff. between master and this branch. Which sounds like a success criteria, so 👍 👍!

I do see this, though:

screen shot 2017-07-28 at 09 12 32

But I see that also in master, and it seems to be related to #2059

@aduth
Copy link
Member Author

aduth commented Jul 28, 2017

Currently this should only affect the visibility popover, not the date picker, but it's intended to be part of a series toward consolidating patterns to a common component (similar to DropDownMenu, #1880).

I'll plan to merge this one after today's release and address schedule popover in a subsequent pull request.

@jasmussen
Copy link
Contributor

👍👍

Necessary to avoid popover bounds exceed detectino from flipping inserter, moving it off-screen in mobile.
@aduth aduth force-pushed the update/visibility-popover branch from 9c459cc to 5a58688 Compare July 31, 2017 19:35
@aduth
Copy link
Member Author

aduth commented Jul 31, 2017

In testing on mobile, I found that the inserter popover was not behaving correctly, but then I noticed the same in master. It appears that our logic for calculating the height of the inserter content was never updated when we added tabs to the inserter. This is accounted for in 5a58688.

@aduth aduth merged commit 7ee9fbb into master Jul 31, 2017
@aduth aduth deleted the update/visibility-popover branch July 31, 2017 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface General Interface Parts of the UI which don't fall neatly under other labels. Mobile Web Viewport sizes for mobile and tablet devices
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants