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

Fix bug where a position: fixed popover content doesn't scroll #1064

Merged

Conversation

chandlerprall
Copy link
Contributor

Fixes #1059 by updating the popover's content position when the page scrolls. The added example may be too obnoxious.

scrolling with the page

As a fun side-effect, this means all popover content repositions with scrolling.

reacting to scroll

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

I think this is really cool but I don't think having the popover move position is a desirable UX.

If I open a popover which contains a form and then I scroll then I think I either a) want to see more content on the page to inform my decision about interacting with the form or b) want the popover to go away because I'm moving my focus to something else.

To step into the mind of the user... in either case, I don't feel in control of the UI if the popover is moving around, trying to stay in view. I'm used to being in control of the UI, and taking the action of scrolling to change the content that's in view. So if I want the popover to be in view, I'll just scroll to it.

I think we need to decide whether users are more a or b, above. There always be exceptions to either one. I think b is the more pleasant experience because in most cases when I scroll, I'm progressing through the UI, not trying to cross-reference two different parts of it.

@cjcenizal
Copy link
Contributor

@cchaos Correct me if I'm wrong but in the cross-referenced issue, it seems like a fixed position element with a popover is more of a special case then a common one right? The only cases where I can think of this being needed is for the app header and for a sidebar like in Canvas. If so, then maybe it merits a prop for turning on the "stay visible while scrolling" behavior.

@chandlerprall
Copy link
Contributor Author

Great point! IMO the popover should be open in response to a user action, and is just as easily closable if they don't want it around. But I'm on the fence either way.

@cchaos @snide thoughts?

@cchaos
Copy link
Contributor

cchaos commented Jul 31, 2018

I'm fine with making it an optional prop, but it is a necessary fix.

@chandlerprall
Copy link
Contributor Author

@cjcenizal @cchaos added repositionOnScroll prop to EuiPopover

Copy link
Contributor

@cjcenizal cjcenizal left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Added some minor stuff I noticed. Rest looks good and think this is a good solution.

@@ -204,5 +207,22 @@ export const PopoverExample = {
</div>
),
demo: <PopoverHTMLElementAnchor />,
}, {
title: 'Popover on a static element',
Copy link
Contributor

Choose a reason for hiding this comment

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

on a fixed element

text: (
<div>
<p>
Popover content even works on <EuiCode>position: static;</EuiCode> elements.
Copy link
Contributor

Choose a reason for hiding this comment

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

fixed element.

);

return (
<EuiPopover
Copy link
Contributor

Choose a reason for hiding this comment

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

In the docs I'd provide a separate button that says "Show fixed popover example", that then toggles the fixed button display so it isn't always shown.

This falls in line with how we handle other fixed content examples in the docs like modals, fixed progress bars, the bottom bar...etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably the best example of doing something like that.

@@ -421,6 +435,7 @@ EuiPopover.propTypes = {
PropTypes.node,
PropTypes.instanceOf(HTMLElement)
]),
repositionOnScroll: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an autodoc for what this does.

@chandlerprall
Copy link
Contributor Author

@snide updated with your requested changes

Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Nice. Looks good to go.

@chandlerprall chandlerprall merged commit b98ab5b into elastic:master Aug 6, 2018
@chandlerprall chandlerprall deleted the bug/1059-popover-onscroll branch August 6, 2018 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants