Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Rename layout ownerState property from isRtl to layoutDirection #15803

Merged
merged 1 commit into from
Dec 9, 2024
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
4 changes: 2 additions & 2 deletions packages/x-date-pickers/src/PickersLayout/PickersLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const PickersLayoutRoot = styled('div', {
},
},
{
props: { pickerOrientation: 'landscape', isRtl: true },
props: { pickerOrientation: 'landscape', layoutDirection: 'rtl' },
style: {
[`& .${pickersLayoutClasses.toolbar}`]: {
gridColumn: 3,
Expand All @@ -66,7 +66,7 @@ export const PickersLayoutRoot = styled('div', {
},
},
{
props: { pickerOrientation: 'portrait', isRtl: true },
props: { pickerOrientation: 'portrait', layoutDirection: 'rtl' },
style: {
[`& .${pickersLayoutClasses.shortcuts}`]: {
gridColumn: 3,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ export interface ExportedPickersLayoutSlots<
}

export interface PickerLayoutOwnerState extends PickerOwnerState {
// 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.
// 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.
/**
* `true` if the application is in right-to-left direction.
* The direction of the layout.
* Is equal to "ltr" when the layout is in left-to-right direction.
* Is equal to "rtl" when the layout is in right-to-left direction.
*/
isRtl: boolean;
layoutDirection: 'ltr' | 'rtl';
}

export interface ExportedPickersLayoutSlotProps<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ const usePickerLayout = <TValue extends PickerValidValue, TView extends DateOrTi
// - For range pickers value: [PickerValidDate | null, PickerValidDate | null]
} = props;

const ownerState: PickerLayoutOwnerState = { ...pickerOwnerState, isRtl };
const ownerState = React.useMemo<PickerLayoutOwnerState>(
() => ({ ...pickerOwnerState, layoutDirection: isRtl ? 'rtl' : 'ltr' }),
[pickerOwnerState, isRtl],
);
const classes = useUtilityClasses(classesProp, ownerState);

// Action bar
Expand Down
Loading