Skip to content

Commit b2d62da

Browse files
committed
Self review cleanup
1 parent 1462ce7 commit b2d62da

File tree

11 files changed

+80
-508
lines changed

11 files changed

+80
-508
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66

77
## Added
88
- Modernized `dcc.Tabs`
9+
- Modernized `dcc.DatePickerSingle` and `dcc.DatePickerRange`
910

1011
## Changed
1112
- `dcc.Tab` now accepts a `width` prop which can be a pixel or percentage width for an individual tab.
@@ -50,7 +51,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
5051
- [#3347](https://github.com/plotly/dash/pull/3347) Added 'api_endpoint' to `callback` to expose api endpoints at the provided path for use to be executed directly without dash.
5152
- [#3445](https://github.com/plotly/dash/pull/3445) Added API to reverse direction of slider component.
5253
- [#3460](https://github.com/plotly/dash/pull/3460) Add `/health` endpoint for server monitoring and health checks.
53-
- [#3465](https://github.com/plotly/dash/pull/3465) Plotly cloud integrations, add devtool API, placeholder plotly cloud CLI & publish button, `dash[cloud]` extra dependencies.
54+
- [#3465](https://github.com/plotly/dash/pull/3465) Plotly cloud integrations, add devtool API, placeholder plotly cloud CLI & publish button, `dash[cloud]` extra dependencies.
5455

5556
## Fixed
5657
- [#3395](https://github.com/plotly/dash/pull/3395) Fix Components added through set_props() cannot trigger related callback functions. Fix [#3316](https://github.com/plotly/dash/issues/3316)

components/dash-core-components/package-lock.json

Lines changed: 39 additions & 273 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/dash-core-components/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
"prop-types": "^15.8.1",
5858
"ramda": "^0.30.1",
5959
"react-addons-shallow-compare": "^15.6.3",
60-
"react-dates": "^21.8.0",
6160
"react-docgen": "^5.4.3",
6261
"react-dropzone": "^4.1.2",
6362
"react-fast-compare": "^3.2.2",

components/dash-core-components/src/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Clipboard from './components/Clipboard.react';
44
import ConfirmDialog from './components/ConfirmDialog.react';
55
import ConfirmDialogProvider from './components/ConfirmDialogProvider.react';
66
import DatePickerRange from './components/DatePickerRange';
7-
// import DatePickerRange from './components/DatePickerRange.react';
87
import DatePickerSingle from './components/DatePickerSingle';
98
import Download from './components/Download.react';
109
import Dropdown from './components/Dropdown';
@@ -27,8 +26,6 @@ import Tooltip from './components/Tooltip';
2726
import Upload from './components/Upload.react';
2827

2928
import './components/css/dcc.css';
30-
import 'react-dates/lib/css/_datepicker.css';
31-
import './components/css/react-dates@20.1.0-fix.css';
3229

3330
export {
3431
Checklist,

components/dash-core-components/tests/unit/calendar/Calendar.test.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,10 @@ describe('Calendar', () => {
213213
expectedFocusedDay: '23',
214214
},
215215
{
216-
description: 'first day when selected date is not visible',
216+
description: 'selected date even when not initially visible',
217217
visibleMonth: new Date(2020, 0, 1),
218218
selectedDate: new Date(2025, 9, 17),
219-
expectedFocusedDay: '1',
219+
expectedFocusedDay: '17', // Calendar switches to October 2025
220220
},
221221
{
222222
description: 'first day when no date is selected',
@@ -227,14 +227,22 @@ describe('Calendar', () => {
227227
])(
228228
'focuses $description',
229229
({visibleMonth, selectedDate, expectedFocusedDay}) => {
230+
const ref = React.createRef<any>();
230231
render(
231232
<Calendar
233+
ref={ref}
232234
onSelectionChange={mockOnSelectionChange}
233235
initialVisibleDate={visibleMonth}
234236
selectionStart={selectedDate}
235237
/>
236238
);
237239

240+
// Imperatively focus the appropriate date
241+
const dateToFocus = selectedDate || visibleMonth;
242+
act(() => {
243+
ref.current?.focusDate(dateToFocus);
244+
});
245+
238246
const focusedElement = document.activeElement;
239247
expect(focusedElement?.tagName).toBe('TD');
240248
expect(focusedElement?.textContent).toBe(expectedFocusedDay);

components/dash-core-components/tests/unit/calendar/CalendarDay.test.tsx

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ describe('CalendarDay', () => {
1313
</tbody>
1414
</table>
1515
);
16-
const td = container.querySelector('td');
17-
if (!td) {
18-
throw new Error('td element not rendered');
19-
}
20-
return td;
16+
return container.querySelector('td')!;
2117
};
2218

2319
it('renders with correct label and inside/outside classes', () => {
@@ -26,32 +22,22 @@ describe('CalendarDay', () => {
2622
isOutside: false,
2723
showOutsideDays: true,
2824
});
29-
expect(insideDay.textContent).toBe('15');
30-
expect(
31-
insideDay.classList.contains('dash-datepicker-calendar-date-inside')
32-
).toBe(true);
33-
expect(
34-
insideDay.classList.contains(
35-
'dash-datepicker-calendar-date-outside'
36-
)
37-
).toBe(false);
25+
expect(insideDay).toHaveTextContent('15');
26+
expect(insideDay).toHaveClass('dash-datepicker-calendar-date-inside');
27+
expect(insideDay).not.toHaveClass(
28+
'dash-datepicker-calendar-date-outside'
29+
);
3830

3931
const outsideDay = renderDay({
4032
date: new Date(2024, 11, 31),
4133
isOutside: true,
4234
showOutsideDays: true,
4335
});
44-
expect(outsideDay.textContent).toBe('31');
45-
expect(
46-
outsideDay.classList.contains(
47-
'dash-datepicker-calendar-date-outside'
48-
)
49-
).toBe(true);
50-
expect(
51-
outsideDay.classList.contains(
52-
'dash-datepicker-calendar-date-inside'
53-
)
54-
).toBe(false);
36+
expect(outsideDay).toHaveTextContent('31');
37+
expect(outsideDay).toHaveClass('dash-datepicker-calendar-date-outside');
38+
expect(outsideDay).not.toHaveClass(
39+
'dash-datepicker-calendar-date-inside'
40+
);
5541
});
5642

5743
it('marks disabled day with correct attributes', () => {
@@ -62,11 +48,9 @@ describe('CalendarDay', () => {
6248
isDisabled: true,
6349
});
6450

65-
expect(
66-
td.classList.contains('dash-datepicker-calendar-date-disabled')
67-
).toBe(true);
68-
expect(td.getAttribute('aria-disabled')).toBe('true');
69-
expect(td.getAttribute('tabIndex')).toBeNull();
51+
expect(td).toHaveClass('dash-datepicker-calendar-date-disabled');
52+
expect(td).toHaveAttribute('aria-disabled', 'true');
53+
expect(td).not.toHaveAttribute('tabIndex');
7054
});
7155

7256
it('hides label for outside days when showOutsideDays is false', () => {
@@ -76,10 +60,8 @@ describe('CalendarDay', () => {
7660
showOutsideDays: false,
7761
});
7862

79-
expect(td.textContent).toBe('');
80-
expect(
81-
td.classList.contains('dash-datepicker-calendar-date-outside')
82-
).toBe(true);
63+
expect(td).toHaveTextContent('');
64+
expect(td).toHaveClass('dash-datepicker-calendar-date-outside');
8365
});
8466

8567
it('focuses element when isFocused is true', () => {

components/dash-core-components/tests/unit/calendar/CalendarDayPadding.test.tsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,11 @@ describe('CalendarDayPadding', () => {
1414
</table>
1515
);
1616
const td = container.querySelector('td');
17-
if (!td) {
18-
throw new Error('td element not rendered');
19-
}
2017

21-
expect(td.classList.contains('dash-datepicker-calendar-padding')).toBe(
22-
true
23-
);
24-
expect(
25-
td.classList.contains('dash-datepicker-calendar-date-inside')
26-
).toBe(false);
27-
expect(
28-
td.classList.contains('dash-datepicker-calendar-date-outside')
29-
).toBe(false);
30-
expect(td.textContent).toBe('');
18+
expect(td).toBeInTheDocument();
19+
expect(td).toHaveClass('dash-datepicker-calendar-padding');
20+
expect(td).not.toHaveClass('dash-datepicker-calendar-date-inside');
21+
expect(td).not.toHaveClass('dash-datepicker-calendar-date-outside');
22+
expect(td).toHaveTextContent('');
3123
});
3224
});

components/dash-core-components/tests/unit/calendar/CalendarMonth.test.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,9 @@ describe('CalendarMonth', () => {
102102
td => td.textContent?.trim() || ''
103103
);
104104

105-
// Behavior 1: When showOutsideDays=true, all cells should be labeled (no empty labels)
106-
// Find cells that are in the actual calendar rows (not ghost rows)
107105
const labeledCells = cellTexts.filter(text => text !== '');
108106

109-
// Behavior 2: Days before January 1 should be labeled (December days)
110-
// First 2 cells should be December days (30, 31)
111-
// January 1, 2025 is Wednesday, which is 2 days after Monday
107+
// First 2 cells should be December days (30, 31), then January 1
112108
expect(cellTexts[0]).toBe('30');
113109
expect(cellTexts[1]).toBe('31');
114110

components/dash-core-components/tests/unit/calendar/DatePickerSingle.test.tsx

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)