Skip to content

feat: refactor Footer component to be accessible#990

Open
Pareder wants to merge 1 commit into
react-component:masterfrom
Pareder:feat/improve-footer-accessibility
Open

feat: refactor Footer component to be accessible#990
Pareder wants to merge 1 commit into
react-component:masterfrom
Pareder:feat/improve-footer-accessibility

Conversation

@Pareder

@Pareder Pareder commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is a small chunk of a big one #972 focusing on Footer accessibility and containing breaking changes.

  • The "Now/Today" control is now a real <button type="button" class="rc-picker-now"> (previously <a class="rc-picker-now-btn">), and the OK control a <button type="button" class="rc-picker-ok">.
  • The presets/ranges container is now a flex <div class="rc-picker-ranges"> instead of <ul>/<li>.

Breaking changes

  1. components.button split into components.nowButton and components.okButton.

    - <Picker components={{ button: MyButton }} />
    + <Picker components={{ nowButton: MyButton, okButton: MyButton }} />
    

    nowButton renders the Now/Today action; okButton renders the confirm action.

  2. Footer DOM / class changes. Custom CSS targeting the old structure must be updated:

    • .rc-picker-now-btn → removed; style .rc-picker-now (now applied directly to the <button>).
    • .rc-picker-ranges > li / ul.rc-picker-ranges.rc-picker-ranges is now a (flex column); the <li> wrappers are gone.
    • The Now/Today control changed from <a> to <button>.

If we need to leave components.button for backwards compatibility and add a deprecation notice please let me know.

Migration

  • Rename components.buttoncomponents.nowButton / components.okButton.
  • Update any CSS overrides for .rc-picker-now-btn, .rc-picker-now a, or .rc-picker-ranges li.

Summary by CodeRabbit

  • 新功能

    • 日期选择器的“当前/确定”操作区域支持更独立的按钮配置,交互方式更一致。
  • Bug 修复

    • 优化了“Now/OK”区域的展示与点击行为,修复部分场景下按钮结构变化带来的交互不一致问题。
    • 多选、范围选择和时间选择相关确认操作的可用性与禁用状态表现更稳定。
  • 测试

    • 更新了相关自动化测试,覆盖新的按钮结构与交互方式。

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

@Pareder is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

将 Footer 中固定的 li/a/Button/ul 结构改为可通过 nowButton/okButton 配置的组件,相应更新了 Components 与 PickerContextProps 接口、RangePicker/SinglePicker 的上下文装配,并移除了旧的 ranges 列表样式。测试文件同步更新了大量 DOM 选择器以匹配新结构。

Changes

按钮组件化重构

Layer / File(s) Summary
类型与上下文契约
src/interface.tsx, src/PickerInput/context.tsx
Components/PickerContextProps 的按钮字段由单一 button 拆分为 nowButton/okButton 两个可选字段。
Footer 渲染重写
src/PickerInput/Popup/Footer.tsx, assets/index.less
Now/Ok 区域从 li+a/Button+ul 结构改为直接渲染 NowButton/OkButton,容器从 ul 改为 div;移除 &-ranges 下的列表样式规则。
上下文装配
src/PickerInput/RangePicker.tsx, src/PickerInput/SinglePicker.tsx
PickerContext value 与 useMemo 依赖从 components.button 改为 components.nowButton/components.okButton
测试选择器同步
tests/components.spec.tsx, tests/multiple.spec.tsx, tests/new-range.spec.tsx, tests/picker.spec.tsx, tests/range.spec.tsx, tests/util/commonUtil.tsx
大量测试用例将 .rc-picker-ok button/.rc-picker-now-btn/.rc-picker-now > a 等选择器更新为 .rc-picker-ok/.rc-picker-now,并更新自定义按钮注入键名。

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Footer
  participant NowButton
  participant OkButton
  participant PickerContext

  PickerContext->>Footer: 提供 nowButton/okButton 配置
  User->>Footer: 点击 Now 区域
  Footer->>NowButton: 渲染并触发 onInternalNow
  User->>Footer: 点击 Ok 区域
  Footer->>OkButton: 渲染并触发 onSubmit
Loading

Suggested reviewers: zombieJ, afc163

Poem

小兔子敲代码到深夜,
把按钮拆成两个乖乖仔 🐰
Now 一跳,Ok 一点,
旧的 ul 已挥手告别~
测试兔们齐排队,
点点 .rc-picker-ok,蹦蹦跳跳笑嘻嘻!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了主要变更:重构 Footer 组件以提升可访问性。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the review. You can try again by commenting /gemini review.

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.81%. Comparing base (6f6bbb3) to head (78b2c53).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #990      +/-   ##
==========================================
- Coverage   98.81%   98.81%   -0.01%     
==========================================
  Files          66       66              
  Lines        2698     2696       -2     
  Branches      749      744       -5     
==========================================
- Hits         2666     2664       -2     
  Misses         29       29              
  Partials        3        3              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/PickerInput/Popup/Footer.tsx`:
- Around line 86-89: The OkButton in Footer.tsx should not pass RangePicker’s
onSubmit directly to the native button onClick, because
triggerPartConfirm(date?) will receive a MouseEvent instead of a date. Update
the OkButton wiring so the click handler invokes onSubmit without forwarding the
event, keeping the confirmation flow in Popup/Footer and RangePicker consistent
and preventing event objects from being treated as dates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 60ca9bc5-a578-4506-ad6f-e03b5abf503e

📥 Commits

Reviewing files that changed from the base of the PR and between 6f6bbb3 and 78b2c53.

📒 Files selected for processing (12)
  • assets/index.less
  • src/PickerInput/Popup/Footer.tsx
  • src/PickerInput/RangePicker.tsx
  • src/PickerInput/SinglePicker.tsx
  • src/PickerInput/context.tsx
  • src/interface.tsx
  • tests/components.spec.tsx
  • tests/multiple.spec.tsx
  • tests/new-range.spec.tsx
  • tests/picker.spec.tsx
  • tests/range.spec.tsx
  • tests/util/commonUtil.tsx
💤 Files with no reviewable changes (1)
  • assets/index.less

Comment on lines 86 to +89
const okNode = needConfirm && (
<li className={`${prefixCls}-ok`}>
<Button disabled={invalid} onClick={onSubmit}>
{locale.ok}
</Button>
</li>
<OkButton type="button" disabled={invalid} className={`${prefixCls}-ok`} onClick={onSubmit}>
{locale.ok}
</OkButton>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

不要把 onSubmit 直接传给原生 buttononClick

这里的 onSubmitRangePicker 中是 triggerPartConfirm(date?)。改成原生 button 后,点击 OK 会把 MouseEvent 作为第一个参数传进去,区间选择的确认流会把事件对象当成日期提交,后续状态会被污染。

建议修复
-  const okNode = needConfirm && (
-    <OkButton type="button" disabled={invalid} className={`${prefixCls}-ok`} onClick={onSubmit}>
+  const okNode = needConfirm && (
+    <OkButton
+      type="button"
+      disabled={invalid}
+      className={`${prefixCls}-ok`}
+      onClick={() => onSubmit()}
+    >
       {locale.ok}
     </OkButton>
   );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const okNode = needConfirm && (
<li className={`${prefixCls}-ok`}>
<Button disabled={invalid} onClick={onSubmit}>
{locale.ok}
</Button>
</li>
<OkButton type="button" disabled={invalid} className={`${prefixCls}-ok`} onClick={onSubmit}>
{locale.ok}
</OkButton>
const okNode = needConfirm && (
<OkButton
type="button"
disabled={invalid}
className={`${prefixCls}-ok`}
onClick={() => onSubmit()}
>
{locale.ok}
</OkButton>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/PickerInput/Popup/Footer.tsx` around lines 86 - 89, The OkButton in
Footer.tsx should not pass RangePicker’s onSubmit directly to the native button
onClick, because triggerPartConfirm(date?) will receive a MouseEvent instead of
a date. Update the OkButton wiring so the click handler invokes onSubmit without
forwarding the event, keeping the confirmation flow in Popup/Footer and
RangePicker consistent and preventing event objects from being treated as dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant