Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dash_core_components/dash_core_components.dev.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_core_components/dash_core_components.dev.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dash_core_components/dash_core_components.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_core_components/dash_core_components.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/DatePickerSingle.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export default class DatePickerSingle extends Component {

onDateChange(date) {
const {setProps} = this.props;
if (setProps && date !== null) {
setProps({date: date.format('YYYY-MM-DD')});
if (setProps) {
setProps({date: date ? date.format('YYYY-MM-DD') : null});
} else {
this.setState({date});
}
Expand Down
2 changes: 2 additions & 0 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,8 @@ def test_tabs_with_children_undefined(self):

self.startServer(app=app)

self.wait_for_element_by_css_selector('#tabs-content')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There was a percy diff - the image produced in this PR prior to this commit was actually the right one, dunno how the incorrect one got approved... but to make that more robust I added this wait for the correct element to be on the page.


self.snapshot('Tabs component with children undefined')

def test_tabs_render_without_selected(self):
Expand Down
35 changes: 35 additions & 0 deletions test/unit/DatePickerSingle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,38 @@ describe('Date can be set properly', () => {
expect(dps.state().date).not.toEqual(null);
});
});

describe('Date can be selected', () => {
test('`setProps` callback is called when date is selected', () => {
const setPropsSpy = jest.fn();
const props = {
date: '2019-01-01',
placeholder: 'My Date',
setProps: setPropsSpy,
};

const dps = mount(<DatePickerSingle {...props} />);
dps.setState({focused: true});
const day = dps.find("[aria-label='Saturday, January 19, 2019']");
day.simulate('click');

expect(setPropsSpy).toHaveBeenCalledWith({date: '2019-01-19'});
});
});

describe('Date can be cleared', () => {
test('`setProps` callback is called when date is cleared', () => {
const setPropsSpy = jest.fn();
const props = {
date: '2019-01-01',
clearable: true,
setProps: setPropsSpy,
};

const dps = mount(<DatePickerSingle {...props} />);
const clearDate = dps.find("[aria-label='Clear Date']");
clearDate.simulate('click');

expect(setPropsSpy).toHaveBeenCalledWith({date: null});
});
});