diff --git a/docs/data/migration/migration-pickers-v6/migration-pickers-v6.md b/docs/data/migration/migration-pickers-v6/migration-pickers-v6.md index 0645f478a89f..cefc302df3c4 100644 --- a/docs/data/migration/migration-pickers-v6/migration-pickers-v6.md +++ b/docs/data/migration/migration-pickers-v6/migration-pickers-v6.md @@ -63,3 +63,28 @@ For example: The same applies to `slotProps` and `componentsProps`. ::: + +## Field components + +### Replace the section `hasLeadingZeros` property + +:::success +This only impacts you if you are using the `unstableFieldRef` prop to imperatively access the section object. +::: + +The property `hasLeadingZeros` has been removed from the sections in favor of the more precise `hasLeadingZerosInFormat` and `hasLeadingZerosInInput` properties. +To keep the same behavior, you can replace it by `hasLeadingZerosInFormat` + +```diff + const fieldRef = React.useRef>(null); + + React.useEffect(() => { + const firstSection = fieldRef.current!.getSections()[0] +- console.log(firstSection.hasLeadingZeros) ++ console.log(firstSection.hasLeadingZerosInFormat) + }, []) + + return ( + + ); +``` diff --git a/packages/x-date-pickers/src/internals/hooks/useField/useField.test.tsx b/packages/x-date-pickers/src/internals/hooks/useField/useField.test.tsx index cf753ed8e5ce..3005eefb7bbb 100644 --- a/packages/x-date-pickers/src/internals/hooks/useField/useField.test.tsx +++ b/packages/x-date-pickers/src/internals/hooks/useField/useField.test.tsx @@ -8,7 +8,6 @@ const COMMON_PROPERTIES = { type: 'year', modified: false, format: 'YYYY', - hasLeadingZeros: true, hasLeadingZerosInFormat: true, maxLength: 4, } as const; diff --git a/packages/x-date-pickers/src/internals/hooks/useField/useField.utils.ts b/packages/x-date-pickers/src/internals/hooks/useField/useField.utils.ts index 10e7196c5978..27e7586c3026 100644 --- a/packages/x-date-pickers/src/internals/hooks/useField/useField.utils.ts +++ b/packages/x-date-pickers/src/internals/hooks/useField/useField.utils.ts @@ -558,7 +558,6 @@ export const splitFormatIntoSections = ( maxLength, value: sectionValue, placeholder: getSectionPlaceholder(utils, timezone, localeText, sectionConfig, token), - hasLeadingZeros: hasLeadingZerosInFormat, hasLeadingZerosInFormat, hasLeadingZerosInInput, startSeparator: sections.length === 0 ? startSeparator : '', diff --git a/packages/x-date-pickers/src/models/fields.ts b/packages/x-date-pickers/src/models/fields.ts index 30e3410328e7..55319f555232 100644 --- a/packages/x-date-pickers/src/models/fields.ts +++ b/packages/x-date-pickers/src/models/fields.ts @@ -44,12 +44,6 @@ export interface FieldSection { * Will determine if we should apply a digit-based editing or a letter-based editing. */ contentType: FieldSectionContentType; - /** - * If `true`, the value of this section is supposed to have leading zeroes when parsed by the date library. - * For example, the value `1` should be rendered as "01" instead of "1". - * @deprecated Will be removed in v7, use `hasLeadingZerosInFormat` instead. - */ - hasLeadingZeros: boolean; /** * If `true`, the value of this section is supposed to have leading zeroes when parsed by the date library. * For example, the value `1` should be rendered as "01" instead of "1".