Skip to content

Commit

Permalink
Merge pull request #133 from heetch/dropdown-modifiers
Browse files Browse the repository at this point in the history
Add support for dropdown modifiers
  • Loading branch information
tamarasaurus authored Apr 17, 2020
2 parents a865700 + 27dd578 commit 3db5b63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/react/src/components/Dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Dropdown = ({
triggerer,
placement,
portalNode,
modifiers,
}) => {
const [isOpen, setIsOpen] = React.useState(isOpenProp);

Expand Down Expand Up @@ -84,6 +85,7 @@ const Dropdown = ({
offset: {
offset: '0, 4px',
},
...modifiers,
}}
innerRef={setPopperNode}
placement={placement}
Expand All @@ -105,6 +107,7 @@ Dropdown.propTypes = {
triggerer: PropTypes.func.isRequired,
placement: PropTypes.string, // https://popper.js.org/docs/v1/#Popper.placements
portalNode: PropTypes.instanceOf(HTMLElement),
modifiers: PropTypes.shape({}), // https://popper.js.org/docs/v1/#modifiers
};

Dropdown.defaultProps = {
Expand All @@ -114,6 +117,7 @@ Dropdown.defaultProps = {
onOpen: () => {},
placement: 'bottom-end',
portalNode: null,
modifiers: {},
};

export default Dropdown;
12 changes: 12 additions & 0 deletions packages/react/src/components/Dropdown/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,17 @@ stories.add('Playground', () => (
<DropdownContainer>
<StoryDropdown portalNode={document.body} />
</DropdownContainer>

<Heading>With modifiers</Heading>
<DropdownContainer>
<StoryDropdown
modifiers={{
preventOverflow: {
enabled: false,
},
}}
portalNode={document.body}
/>
</DropdownContainer>
</>
));

1 comment on commit 3db5b63

@vercel
Copy link

@vercel vercel bot commented on 3db5b63 Apr 17, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.