Skip to content

Commit 2ceba8e

Browse files
committed
Fix --open className not added when widgets are open
Closes #190
1 parent 71865ad commit 2ceba8e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/DateTimePicker.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,15 +435,15 @@ export default class DateTimePicker extends PureComponent {
435435
render() {
436436
const { eventProps } = this;
437437
const { className, disabled } = this.props;
438-
const { isOpen } = this.state;
438+
const { isCalendarOpen, isClockOpen } = this.state;
439439

440440
const { onChange, ...eventPropsWithoutOnChange } = eventProps;
441441

442442
return (
443443
<div
444444
className={mergeClassNames(
445445
baseClassName,
446-
`${baseClassName}--${isOpen ? 'open' : 'closed'}`,
446+
`${baseClassName}--${isCalendarOpen || isClockOpen ? 'open' : 'closed'}`,
447447
`${baseClassName}--${disabled ? 'disabled' : 'enabled'}`,
448448
className,
449449
)}

src/DateTimePicker.spec.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,22 @@ describe('DateTimePicker', () => {
148148
expect(wrapper).toHaveClass(className);
149149
});
150150

151+
it('applies "--open" className to its wrapper when given isCalendarOpen flag', () => {
152+
const { container } = render(<DateTimePicker isCalendarOpen />);
153+
154+
const wrapper = container.firstChild;
155+
156+
expect(wrapper).toHaveClass('react-datetime-picker--open');
157+
});
158+
159+
it('applies "--open" className to its wrapper when given isClockOpen flag', () => {
160+
const { container } = render(<DateTimePicker isClockOpen />);
161+
162+
const wrapper = container.firstChild;
163+
164+
expect(wrapper).toHaveClass('react-datetime-picker--open');
165+
});
166+
151167
it('applies calendarClassName to the calendar when given a string', () => {
152168
const calendarClassName = 'testClassName';
153169

0 commit comments

Comments
 (0)