-
Notifications
You must be signed in to change notification settings - Fork 842
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
Fix bug where a position: fixed popover content doesn't scroll #1064
Conversation
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 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.
@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. |
I'm fine with making it an optional prop, but it is a necessary fix. |
@cjcenizal @cchaos added |
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.
LGTM!
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.
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', |
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.
on a fixed element
text: ( | ||
<div> | ||
<p> | ||
Popover content even works on <EuiCode>position: static;</EuiCode> elements. |
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.
fixed element.
); | ||
|
||
return ( | ||
<EuiPopover |
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.
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.
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.
src/components/popover/popover.js
Outdated
@@ -421,6 +435,7 @@ EuiPopover.propTypes = { | |||
PropTypes.node, | |||
PropTypes.instanceOf(HTMLElement) | |||
]), | |||
repositionOnScroll: PropTypes.bool, |
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.
Add an autodoc for what this does.
@snide updated with your requested changes |
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.
Nice. Looks good to go.
Fixes #1059 by updating the popover's content position when the page scrolls. The added example may be too obnoxious.
As a fun side-effect, this means all popover content repositions with scrolling.