Skip to content

Commit

Permalink
feat(DropdownMenu): allow menu to persist
Browse files Browse the repository at this point in the history
Add persist prop to DropdownMenu. When true, the DropdownMenu will always render a Popper and not remove it when hidden.
This prop allows the children to persist their state and not be re-initialized when the menu opens/closes.

Fixes #779
  • Loading branch information
TheSharpieOne committed Apr 19, 2018
1 parent 0f4a4cb commit 840adb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/lib/Components/DropdownsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ DropdownMenu.propTypes = {
className: PropTypes.string,
cssModule: PropTypes.object,
// Custom modifiers that are passed to DropdownMenu.js, see https://popper.js.org/popper-documentation.html#modifiers
modifiers: PropTypes.object
modifiers: PropTypes.object,
persist: PropTypes.bool // presist the popper, even when closed. See #779 for reasoning
};
DropdownItem.propTypes = {
Expand Down
3 changes: 2 additions & 1 deletion src/DropdownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const propTypes = {
modifiers: PropTypes.object,
className: PropTypes.string,
cssModule: PropTypes.object,
persist: PropTypes.bool,
};

const defaultProps = {
Expand Down Expand Up @@ -47,7 +48,7 @@ const DropdownMenu = (props, context) => {

let Tag = tag;

if (context.isOpen && !context.inNavbar) {
if (persist || (context.isOpen && !context.inNavbar) {
Tag = Popper;

const position1 = directionPositionMap[context.direction] || 'bottom';
Expand Down

0 comments on commit 840adb2

Please sign in to comment.