-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Site Picker: Scroll to selected site when opening picker #1641
Conversation
This is looking good! :) I was thinking to tweak the position we scroll back it to, but I played a bit with different mechanics and in the end I feel tha the one you choose that scrolls up to half of the previous item works well. Design wise: 👍 |
@@ -8,7 +8,6 @@ var React = require( 'react' ), | |||
* Internal dependencies | |||
*/ | |||
var Popover = require( 'components/popover' ), | |||
sitesList = require( 'lib/sites-list' )(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was here to make the component self-sufficient in a way. cc @aduth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was here to make the component self-sufficient in a way. cc @aduth
I honestly don't recall, though I'd agree that could be an argument for keeping it the way it was. Was there a reason this change was made?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes: <SitesPopover>
needs to either use a sites list coming from a parent who is going to observe
it and pass changes down to us, or observe
it by itself. I don't have a preference on which way that is accomplished, this way just seemed simpler at the time.
}, | ||
|
||
scrollIntoView: function() { | ||
var node = ReactDom.findDOMNode( this ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than pulling in react-dom
to use the findDOMNode
method, you could alternatively use a ref
on the rendered root div
, which would make this method a bit simpler and lose the extra dependency:
scrollIntoView() {
const parentScrollTop = this.refs.site.offsetTop;
if ( this.refs.site.previousSibling ) {
parentScrollTop -= this.refs.site.previousSibling.offsetHeight / 2;
}
this.refs.site.parentNode.scrollTop = parentScrollTop;
},
render() {
return <div ref="site" className={ siteClass } />;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that better too. Done in caafe71.
@folletto I was hoping a designer could take a look at the hover styles in particular. To clarify, there are a couple of problems:
|
Looking at #1507 it seems like there are a few issues at play here:
Updating the scroll position to bring the selected site into view kind of solves the first issue, but doesn't have much of an affect on the second issue—its still not obvious that clicking the selected site brings you back. I think the second issue is solved with @nb's suggestion:
Keeping that I do have one issue with the magic scrolling: How it behaves as you move around Calypso. For instance, when you're on Reader, none of this stuff happens in the Masterbar's new post button. I get why, but most people won't understand the distinction. |
The main problem with moving sites around in the list is that you break the consistency of the order of the list, which imposes additional cognitive burden on the user. This is even worse for typical users with 2 or 3 sites - keep in mind that a12s with our 50-100+ sites are a bit of an edge case. From the sidebar picker, there are already two ways to get back to the page you were on:
I'm not sure I follow. Neither PR makes that change. They both accomplish the same thing - ensuring that the selected site is always visible. This one by scrolling, and #1507 by rearranging the list. On the Reader or any other "All My Sites" view, there is no currently selected site. We could add some logic to select a default site for the new post button, but that should be a separate change. |
Yeah, I noticed that too. In the sidebar we have two different states for selected and hover, I'd use the same pattern, keeping the blue for hover (since that's a standard for our white controls) but use a subdued look for the pre-selected one. Or, which might be better, at least as the initial step: we can skip pre-highlighting in the dropdown: in the end the scrolling position might be enough (let's just add the class, so styling will be quick and can be prototyped).
That's... true. I've no preference there. But might be another reason to start with no highlight in the masterbar, just scroll, and then we'll see? |
This commit modifies the site pickers (both in the sidebar and in the new post popover) to scroll to the selected site upon a change in site. This makes it easier to jump straight back to the current site you're working on, which is the most common use case.
For my test site (nylen.io/blog) we weren't checking against the site slug correctly. This commit restores the highlighting in the sidebar when this site (and probably others) are active.
This makes it more visually obvious that more sites are available by scrolling up.
caafe71
to
daa4e7d
Compare
Oh, I wasn't aware that it was a standard hover style. Let's leave it alone for now then. I think the highlight on the selected site is important to keep. In daa4e7d I've made it take precedence over the hover style so we are consistent there. Rebased after recent masterbar changes (#631) - this is a good improvement that I've wished for on other branches today and I'd like to merge it soon. Anyone want to give a final review? |
Reviewing it... I'm not 100% satisfied with the default state because the dropdown has a different scope than the sidebar: the sidebar highlight exists because selecting it is a "null" operation: you are already on it. In the dropdown instead you can actively select that, the selected state is not just an option, but THE option you're likely to take. Which leads me to say:
|
daa4e7d
to
a378da7
Compare
OK, I've removed that commit so we are back to the previous behavior now. I probably spent too much time on these silly hover styles anyway. Thanks for taking another look. |
I just tested this and it works really well! I was going to say that we forgot to document the readme.md with the new props. but it looks like we don't have such documentation at all. 😿 That part could be done in a new PR. |
…lected Site Picker: Scroll to selected site when opening picker
This PR seeks to accomplish the same goal as #1507: making it easier to select the current site in the site picker.
Here we do that by scrolling to the selected site when the sites picker is loaded or updated:
We intentionally show half of the previous site (if any) to make it visually obvious that there are more sites available if you scroll up.
I've also added a highlight to the selected site in the sites picker that appears when you click the "New Post" icon in the masterbar. I used the same selected colors as the sidebar. Marking as Needs Design Review because of that, and because the hover effects in particular need some love:
Plus a bit of trash pickup along the way:
nylen.io/blog
by matching against site slug correctly. Currently we have boththis.props.sites.selected
andthis.props.selected
, we should probably get rid of one of these for clarity. cc @mtias - looks like you're working on changes in this area of the code.border-radius
of the popover. This is done by setting the scrollable parent tooverflow: hidden
(reference).