Skip to content

Commit

Permalink
[CalendarPicker] Prevent getting focus when autoFocus=false (#6304) (
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Oct 3, 2022
1 parent c25410b commit 7998b9d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/x-date-pickers/src/CalendarPicker/CalendarPicker.tsx
Expand Up @@ -445,8 +445,13 @@ export const CalendarPicker = React.forwardRef(function CalendarPicker<TDate>(
},
);

const prevOpenViewRef = React.useRef(openView);
React.useEffect(() => {
// Set focus to the button when switching from a view to another
if (prevOpenViewRef.current === openView) {
return;
}
prevOpenViewRef.current = openView;
handleFocusedViewChange(openView)(true);
}, [openView, handleFocusedViewChange]);

Expand Down

0 comments on commit 7998b9d

Please sign in to comment.