Skip to content

Commit 722e8f6

Browse files
Fix
1 parent 85e9e54 commit 722e8f6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/x-date-pickers/src/DateCalendar/tests/DateCalendar.test.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ describe('<DateCalendar />', () => {
638638

639639
const renderCountBeforeChange = RenderCount.callCount;
640640
fireEvent.click(screen.getByRole('gridcell', { name: '2' }));
641-
expect(RenderCount.callCount - renderCountBeforeChange).to.equal(4); // 2 render * 2 days
641+
// 2 render (one to update tabIndex + autoFocus, one to update selection) * 2 days * 2 (because dev mode)
642+
expect(RenderCount.callCount - renderCountBeforeChange).to.equal(8);
642643
});
643644
});
644645
});

packages/x-date-pickers/src/PickersDay/PickersDay.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@ const PickersDayFiller = styled('div', {
231231

232232
const noop = () => {};
233233

234+
const useUpdateTracking = (props) => {
235+
const oldProps = React.useRef(props);
236+
237+
React.useEffect(() => {
238+
// eslint-disable-next-line no-console
239+
console.log(
240+
props.day.toString(),
241+
Object.keys(props)
242+
.map((key) => ({ key, current: props[key], old: oldProps.current[key] }))
243+
.filter(({ old, current }) => old !== current),
244+
);
245+
246+
oldProps.current = props;
247+
});
248+
};
249+
234250
type PickersDayComponent = ((
235251
props: PickersDayProps & React.RefAttributes<HTMLButtonElement>,
236252
) => React.JSX.Element) & { propTypes?: any };
@@ -270,6 +286,8 @@ const PickersDayRaw = React.forwardRef(function PickersDay(
270286
...other
271287
} = props;
272288

289+
// useUpdateTracking(props);
290+
273291
const ownerState = {
274292
...props,
275293
autoFocus,

0 commit comments

Comments
 (0)