Skip to content

fix[data-picker]: hide Now when current time is disabled #6152

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

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 10 additions & 2 deletions components/vc-picker/PickerPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ function PickerPanel<DateType>() {
isMinuteStepValid.value ? minuteStep : 1,
isSecondStepValid.value ? secondStep : 1,
);

const adjustedNow = setTime(
generateConfig,
now,
Expand Down Expand Up @@ -414,14 +415,21 @@ function PickerPanel<DateType>() {
disabledDate,
picker = 'date',
tabindex = 0,
showNow,
showTime,
showToday,
renderExtraFooter,
onMousedown,
onOk,
components,
} = props;

let { showNow } = props;
const now = generateConfig.getNow();
// when NOW is invalid, hide NOW button
if (disabledDate?.(now)) {
showNow = false;
}

if (operationRef && panelPosition.value !== 'right') {
operationRef.value = {
onKeydown: onInternalKeydown,
Expand Down Expand Up @@ -578,7 +586,7 @@ function PickerPanel<DateType>() {
if (showToday && mergedMode.value === 'date' && picker === 'date' && !showTime) {
const now = generateConfig.getNow();
const todayCls = `${prefixCls}-today-btn`;
const disabled = disabledDate && disabledDate(now);
const disabled = disabledDate?.(now);
todayNode = (
<a
class={classNames(todayCls, disabled && `${todayCls}-disabled`)}
Expand Down