-
Notifications
You must be signed in to change notification settings - Fork 841
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
Changes from 2 commits
a176136
e51dfc6
f01eefd
2eb9f8e
4369a5f
f861bb0
e61097f
74999dc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,9 @@ import PopoverContainer from './popover_container'; | |
const popoverContainerSource = require('!!raw-loader!./popover_container'); | ||
const popoverContainerHtml = renderToHtml(PopoverContainer); | ||
|
||
import PopoverFixed from './popover_fixed'; | ||
const popoverFixedSource = require('!!raw-loader!./popover_fixed'); | ||
const popoverFixedHtml = renderToHtml(PopoverFixed); | ||
|
||
export const PopoverExample = { | ||
title: 'Popover', | ||
|
@@ -204,5 +207,22 @@ export const PopoverExample = { | |
</div> | ||
), | ||
demo: <PopoverHTMLElementAnchor />, | ||
}, { | ||
title: 'Popover on a static element', | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: popoverFixedSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: popoverFixedHtml, | ||
}], | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. fixed element. |
||
</p> | ||
</div> | ||
), | ||
demo: <PopoverFixed />, | ||
}], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import { | ||
EuiButton, | ||
EuiPopover, | ||
} from '../../../../src/components'; | ||
|
||
export default class PopoverContainer extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
isPopoverOpen: false, | ||
}; | ||
} | ||
|
||
onButtonClick = () => { | ||
this.setState({ | ||
isPopoverOpen: !this.state.isPopoverOpen, | ||
}); | ||
} | ||
|
||
closePopover = () => { | ||
this.setState({ | ||
isPopoverOpen: false, | ||
}); | ||
} | ||
|
||
setPanelRef = node => this.panel = node; | ||
|
||
render() { | ||
const button = ( | ||
<EuiButton | ||
iconType="arrowDown" | ||
iconSide="right" | ||
onClick={this.onButtonClick} | ||
style={{ background: 'white' }} | ||
> | ||
Show fixed popover | ||
</EuiButton> | ||
); | ||
|
||
return ( | ||
<EuiPopover | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
button={button} | ||
isOpen={this.state.isPopoverOpen} | ||
closePopover={this.closePopover} | ||
style={{ position: 'fixed', bottom: 50, right: 50 }} | ||
> | ||
<div> | ||
This popover scrolls with the button element! | ||
</div> | ||
</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.
on a fixed element