Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
fix(Dropdown): Support for configuring dropdown offset (#17)
Browse files Browse the repository at this point in the history
* Allow offset to be configured, set offset default

* PR comments: specify proptype

* Move width default, add width proptype

* PR comment: assign offset via destructuring props
  • Loading branch information
cehsu authored Feb 15, 2019
1 parent e1614e4 commit c739ff3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DropdownTrigger = createComponent({

const DropdownMenu = createComponent({
name: 'DropdownMenu',
style: ({ width = 150, theme }) => css`
style: ({ width, theme }) => css`
z-index: 10;
position: absolute;
background: white;
Expand All @@ -33,15 +33,19 @@ export default class Dropdown extends React.Component {
render: PropTypes.func,
autoclose: PropTypes.bool,
placement: PropTypes.string,
offset: PropTypes.string,
boundariesElement: PropTypes.string,
on: PropTypes.string,
width: PropTypes.number,
};

static defaultProps = {
autoclose: true,
offset: '0, 10',
placement: 'bottom-start',
boundariesElement: 'window',
on: 'click',
width: 150,
};

triggerRef = React.createRef();
Expand Down Expand Up @@ -71,7 +75,7 @@ export default class Dropdown extends React.Component {
}

show = () => {
const { placement, boundariesElement } = this.props;
const { placement, boundariesElement, offset } = this.props;

this.setState(
{
Expand All @@ -82,7 +86,7 @@ export default class Dropdown extends React.Component {
placement,
modifiers: {
offset: {
offset: '0, 10',
offset,
},
flip: {
behavior: ['left', 'bottom', 'top', 'right'],
Expand Down

0 comments on commit c739ff3

Please sign in to comment.