Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Disabled date entered manually is not reverted on blur

未关闭
#1,018 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react, typescript
领域
frontend

调研方向

Start by tracing the blur path through flushFieldSubmit, triggerSubmitChange, and the popup-close handling described in the issue; compare it with the Enter path and the previous useRangeValue reset behavior. Add or update a regression test for a controlled picker with a rejected disabledDate, then verify blur restores the selected value while Enter continues to do so.

由索引模型根据 Issue 内容生成。

描述

Description

Since @rc-component/picker 1.12.0, manually entering a date rejected by disabledDate and then blurring the input leaves the rejected date displayed.

In 1.11.0, the input reverted to the previously selected value after blur.

Enter and blur now behave differently: pressing Enter restores the previous value, while blurring leaves the disabled date in the input.

Reproduction

Use a controlled single date picker with:

  • Moment generateConfig
  • Format: MM/DD/YYYY
  • Value: 06/15/2026
  • disabledDate rejecting dates before 06/01/2026
  • State updated only through onChange
  1. Focus the input.
  2. Replace its contents with 03/15/2026.
  3. Click outside the picker.
Expected behavior

The disabled date is rejected, and the input displays the previously selected value, 06/15/2026, consistent with version 1.11.0.

Actual behavior

The input continues to display 03/15/2026, although onChange does not accept that date and the controlled value remains 06/15/2026.

Repeating the same steps but pressing Enter instead of clicking outside restores 06/15/2026.

Minimal example
import React, { useState } from 'react';
import Picker from '@rc-component/picker';
import momentConfig from '@rc-component/picker/lib/generate/moment';
import enUS from '@rc-component/picker/lib/locale/en_US';
import moment from 'moment';

const format = 'MM/DD/YYYY';
const minDate = moment('06/01/2026', format);

export default function Example() {
  const [value, setValue] = useState(moment('06/15/2026', format));

  return (
    <Picker
      generateConfig={momentConfig}
      locale={enUS}
      format={format}
      value={value}
      disabledDate={(date) => date.isBefore(minDate, 'day')}
      onChange={setValue}
    />
  );
}
Versions verified
  • 1.11.0: previous value is restored on blur.
  • 1.12.0: disabled date remains displayed on blur.
  • 1.15.0: same behavior as 1.12.0.
Possible cause

This appears related to PR #994, which introduced useRangeValueChange.

Previously, useRangeValue reset the temporary calendar value to mergedValue after the interaction ended.

In the new flow, flushFieldSubmit calls triggerSubmitChange and closes the popup without handling its false return value. When disabledDate rejects the submission, the temporary calendar value is not reset on blur.

After Enter, the interaction is already completed when popupClose is processed, which takes the reset path and restores the previous value.

主要语言
TypeScript
星标
304
派生
347
平均合并
1 天 2 小时
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

react-component/picker 的其他 Issue

查看 react-component/picker 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。