Skip to content
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 set visibility to hidden for day picker component #1967

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/DayPicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ class DayPicker extends React.PureComponent {
verticalBorderSpacing,
horizontalMonthPadding,
navPosition,
hidden
} = this.props;

const { reactDates: { spacing: { dayPickerHorizontalPadding } } } = theme;
Expand Down Expand Up @@ -1144,7 +1145,7 @@ class DayPicker extends React.PureComponent {
isHorizontal && withPortal && styles.DayPicker_portal__horizontal,
this.isVertical() && withPortal && styles.DayPicker_portal__vertical,
dayPickerStyle,
!monthTitleHeight && styles.DayPicker__hidden,
hidden && styles.DayPicker__hidden,
!noBorder && styles.DayPicker__withBorder,
)}
>
Expand Down
27 changes: 27 additions & 0 deletions stories/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,30 @@ function renderNavNextButton(buttonProps) {
);
}

class TestWrapper extends React.Component {
constructor(props) {
super(props);
this.state = {
showDatePicker: false,
};
}

render() {
const { showDatePicker } = this.state;
return (
<div>
<button
type="button"
onClick={() => this.setState({ showDatePicker: !showDatePicker })}
>
{showDatePicker ? 'Show' : 'Hide'}
</button>
<DayPicker hidden={showDatePicker} />
</div>
);
}
}

storiesOf('DayPicker', module)
.add('default', withInfo()(() => (
<DayPicker />
Expand Down Expand Up @@ -226,4 +250,7 @@ storiesOf('DayPicker', module)
)))
.add('noBorder', withInfo()(() => (
<DayPicker noBorder />
)))
.add('hide', withInfo()(() => (
<TestWrapper />
)));