Skip to content

Commit 0b7ef76

Browse files
authored
fix(DatePicker, TimePicker): clear button accessibility (ant-design#58132)
1 parent c236de7 commit 0b7ef76

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

components/date-picker/style/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { CSSObject } from '@ant-design/cssinjs';
22
import { unit } from '@ant-design/cssinjs';
33

44
import { genPlaceholderStyle, initInputToken } from '../../input/style';
5-
import { resetComponent, textEllipsis } from '../../style';
5+
import { genFocusOutline, resetComponent, textEllipsis } from '../../style';
66
import { genCompactItemStyle } from '../../style/compact-item';
77
import {
88
initMoveMotion,
@@ -210,6 +210,7 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
210210
transform: 'translateY(-50%)',
211211
cursor: 'pointer',
212212
opacity: 0,
213+
pointerEvents: 'none',
213214
transition: ['opacity', 'color'].map((prop) => `${prop} ${motionDurationMid}`).join(', '),
214215

215216
'> *': {
@@ -219,11 +220,18 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
219220
'&:hover': {
220221
color: colorIcon,
221222
},
223+
224+
'&:focus-visible': {
225+
color: token.colorIcon,
226+
borderRadius: token.borderRadiusSM,
227+
...genFocusOutline(token),
228+
},
222229
},
223230

224-
'&:hover': {
231+
'&:hover, &:focus-within': {
225232
[`${componentCls}-clear`]: {
226233
opacity: 1,
234+
pointerEvents: 'auto',
227235
},
228236
// Should use the following selector, but since `:has` has poor compatibility,
229237
// we use `:not(:last-child)` instead, which may cause some problems in some cases.

0 commit comments

Comments
 (0)