-
-
Notifications
You must be signed in to change notification settings - Fork 339
feat: Improve Date panel keyboard navigation and semantics #986
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,24 +23,23 @@ export default function PresetPanel<DateType extends object = any>( | |
|
|
||
| return ( | ||
| <div className={`${prefixCls}-presets`}> | ||
| <ul> | ||
| {presets.map(({ label, value }, index) => ( | ||
| <li | ||
| key={index} | ||
| onClick={() => { | ||
| onClick(executeValue(value)); | ||
| }} | ||
| onMouseEnter={() => { | ||
| onHover(executeValue(value)); | ||
| }} | ||
| onMouseLeave={() => { | ||
| onHover(null); | ||
| }} | ||
| > | ||
| {label} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| {presets.map(({ label, value }, index) => ( | ||
| <button | ||
| key={index} | ||
| type="button" | ||
| onClick={() => { | ||
| onClick(executeValue(value)); | ||
| }} | ||
| onMouseEnter={() => { | ||
| onHover(executeValue(value)); | ||
| }} | ||
| onMouseLeave={() => { | ||
| onHover(null); | ||
| }} | ||
|
Comment on lines
+27
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this PR focuses on improving keyboard navigation and accessibility, we should ensure that preset buttons also trigger the hover preview state when they receive focus via keyboard tab navigation. Adding |
||
| > | ||
| {label} | ||
| </button> | ||
| ))} | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,6 +29,7 @@ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElem | |||||||||||||||||||||||||||
| format?: string; | ||||||||||||||||||||||||||||
| validateFormat: (value: string) => boolean; | ||||||||||||||||||||||||||||
| active?: boolean; | ||||||||||||||||||||||||||||
| open?: boolean; | ||||||||||||||||||||||||||||
| /** Used for single picker only */ | ||||||||||||||||||||||||||||
| showActiveCls?: boolean; | ||||||||||||||||||||||||||||
| suffixIcon?: React.ReactNode; | ||||||||||||||||||||||||||||
|
|
@@ -52,6 +53,7 @@ const Input = React.forwardRef<InputRef, InputProps>((props, ref) => { | |||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||
| className, | ||||||||||||||||||||||||||||
| active, | ||||||||||||||||||||||||||||
| open, | ||||||||||||||||||||||||||||
| showActiveCls = true, | ||||||||||||||||||||||||||||
| suffixIcon, | ||||||||||||||||||||||||||||
| format, | ||||||||||||||||||||||||||||
|
|
@@ -405,6 +407,8 @@ const Input = React.forwardRef<InputRef, InputProps>((props, ref) => { | |||||||||||||||||||||||||||
| <Component | ||||||||||||||||||||||||||||
| ref={inputRef} | ||||||||||||||||||||||||||||
| aria-invalid={invalid} | ||||||||||||||||||||||||||||
| aria-haspopup="dialog" | ||||||||||||||||||||||||||||
| aria-expanded={open} | ||||||||||||||||||||||||||||
| autoComplete="off" | ||||||||||||||||||||||||||||
|
Comment on lines
407
to
412
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to ARIA specifications, the
Suggested change
|
||||||||||||||||||||||||||||
| {...restProps} | ||||||||||||||||||||||||||||
| onKeyDown={onSharedKeyDown} | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
补上预设按钮的样式重置。
这里把
li换成原生button后,只改了容器布局,没有重置按钮自身样式。浏览器默认的边框、内边距、背景和字体会直接暴露出来,预设面板会出现明显的视觉回归,而且不同浏览器表现也不一致。建议修改
&-presets { display: flex; flex-direction: column; gap: 4px; background: `#ccccff`; + + > button { + padding: 0; + font: inherit; + color: inherit; + text-align: start; + background: transparent; + border: 0; + cursor: pointer; + } }📝 Committable suggestion
🤖 Prompt for AI Agents