Skip to content

Commit 183449d

Browse files
flaviendelangleLukasTy
authored andcommitted
[pickers] Rename layout ownerState property from isRtl to layoutDirection (mui#15803)
1 parent a0f0921 commit 183449d

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const PickersLayoutRoot = styled('div', {
4848
},
4949
},
5050
{
51-
props: { pickerOrientation: 'landscape', isRtl: true },
51+
props: { pickerOrientation: 'landscape', layoutDirection: 'rtl' },
5252
style: {
5353
[`& .${pickersLayoutClasses.toolbar}`]: {
5454
gridColumn: 3,
@@ -66,7 +66,7 @@ export const PickersLayoutRoot = styled('div', {
6666
},
6767
},
6868
{
69-
props: { pickerOrientation: 'portrait', isRtl: true },
69+
props: { pickerOrientation: 'portrait', layoutDirection: 'rtl' },
7070
style: {
7171
[`& .${pickersLayoutClasses.shortcuts}`]: {
7272
gridColumn: 3,

packages/x-date-pickers/src/PickersLayout/PickersLayout.types.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ export interface ExportedPickersLayoutSlots<
4040
}
4141

4242
export interface PickerLayoutOwnerState extends PickerOwnerState {
43-
// isRTL cannot be part of PickerOwnerState because we need to have the correct isRTL value even when there is not picker above for some components.
43+
// The direction cannot be part of PickerOwnerState because we need to have the correct direction value even when there is no picker above for standalone components.
4444
/**
45-
* `true` if the application is in right-to-left direction.
45+
* The direction of the layout.
46+
* Is equal to "ltr" when the layout is in left-to-right direction.
47+
* Is equal to "rtl" when the layout is in right-to-left direction.
4648
*/
47-
isRtl: boolean;
49+
layoutDirection: 'ltr' | 'rtl';
4850
}
4951

5052
export interface ExportedPickersLayoutSlotProps<

packages/x-date-pickers/src/PickersLayout/usePickerLayout.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,10 @@ const usePickerLayout = <TValue extends PickerValidValue, TView extends DateOrTi
6969
// - For range pickers value: [PickerValidDate | null, PickerValidDate | null]
7070
} = props;
7171

72-
const ownerState: PickerLayoutOwnerState = { ...pickerOwnerState, isRtl };
72+
const ownerState = React.useMemo<PickerLayoutOwnerState>(
73+
() => ({ ...pickerOwnerState, layoutDirection: isRtl ? 'rtl' : 'ltr' }),
74+
[pickerOwnerState, isRtl],
75+
);
7376
const classes = useUtilityClasses(classesProp, ownerState);
7477

7578
// Action bar

0 commit comments

Comments
 (0)