From 54ae9771d11c76d573be8a068c49442758cd701d Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 28 Feb 2024 16:43:50 +0200 Subject: [PATCH] Check for global `disabled` only once --- .../MultiSectionDigitalClock/MultiSectionDigitalClock.tsx | 7 +++---- .../MultiSectionDigitalClockSection.tsx | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClock.tsx b/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClock.tsx index 3aae2c8dcb262..5c309e3f02e48 100644 --- a/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClock.tsx +++ b/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClock.tsx @@ -292,7 +292,7 @@ export const MultiSectionDigitalClock = React.forwardRef(function MultiSectionDi value, ampm, utils, - isDisabled: (hours) => disabled || isTimeDisabled(hours, 'hours'), + isDisabled: (hours) => isTimeDisabled(hours, 'hours'), timeStep: timeSteps.hours, resolveAriaLabel: localeText.hoursClockNumberText, valueOrReferenceDate, @@ -312,7 +312,7 @@ export const MultiSectionDigitalClock = React.forwardRef(function MultiSectionDi items: getTimeSectionOptions({ value: utils.getMinutes(valueOrReferenceDate), utils, - isDisabled: (minutes) => disabled || isTimeDisabled(minutes, 'minutes'), + isDisabled: (minutes) => isTimeDisabled(minutes, 'minutes'), resolveLabel: (minutes) => utils.format(utils.setMinutes(now, minutes), 'minutes'), timeStep: timeSteps.minutes, hasValue: !!value, @@ -333,7 +333,7 @@ export const MultiSectionDigitalClock = React.forwardRef(function MultiSectionDi items: getTimeSectionOptions({ value: utils.getSeconds(valueOrReferenceDate), utils, - isDisabled: (seconds) => disabled || isTimeDisabled(seconds, 'seconds'), + isDisabled: (seconds) => isTimeDisabled(seconds, 'seconds'), resolveLabel: (seconds) => utils.format(utils.setSeconds(now, seconds), 'seconds'), timeStep: timeSteps.seconds, hasValue: !!value, @@ -384,7 +384,6 @@ export const MultiSectionDigitalClock = React.forwardRef(function MultiSectionDi meridiemMode, setValueAndGoToNextView, valueOrReferenceDate, - disabled, isTimeDisabled, handleMeridiemChange, ], diff --git a/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClockSection.tsx b/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClockSection.tsx index 504d2cf7c5215..ced9449549135 100644 --- a/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClockSection.tsx +++ b/packages/x-date-pickers/src/MultiSectionDigitalClock/MultiSectionDigitalClockSection.tsx @@ -189,7 +189,7 @@ export const MultiSectionDigitalClockSection = React.forwardRef( {items.map((option, index) => { const isItemDisabled = option.isDisabled?.(option.value); const isDisabled = disabled || isItemDisabled; - if (skipDisabled && isItemDisabled) { + if (skipDisabled && isDisabled) { return null; } const isSelected = option.isSelected(option.value);