Skip to content

Commit 2dcf6c3

Browse files
forlpeng.yang
andauthored
fix: add tabIndex support (#64)
Co-authored-by: peng.yang <[email protected]>
1 parent 9dbabb7 commit 2dcf6c3

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

examples/basic.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default () => {
3333
<div>
3434
<h1>Value: {value ? value.format('YYYY-MM-DD HH:mm:ss') : 'null'}</h1>
3535

36-
<div style={{ display: 'flex' }}>
36+
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
3737
<div style={{ margin: '0 8px' }}>
3838
<h3>Basic</h3>
3939
<Picker<Moment> {...sharedProps} locale={zhCN} />
@@ -121,6 +121,10 @@ export default () => {
121121
<h3>Year</h3>
122122
<Picker<Moment> {...sharedProps} locale={zhCN} picker="year" />
123123
</div>
124+
<div style={{ margin: '0 8px' }}>
125+
<h3>Keyboard navigation (Tab key) disabled</h3>
126+
<Picker<Moment> {...sharedProps} locale={enUS} tabIndex={-1} />
127+
</div>
124128
</div>
125129
</div>
126130
);

src/Picker.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface PickerSharedProps<DateType> extends React.AriaAttributes {
4545
allowClear?: boolean;
4646
autoFocus?: boolean;
4747
disabled?: boolean;
48+
tabIndex?: number;
4849
open?: boolean;
4950
defaultOpen?: boolean;
5051
/** Make input readOnly to avoid popup keyboard in mobile */
@@ -129,6 +130,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
129130
const {
130131
prefixCls = 'rc-picker',
131132
id,
133+
tabIndex,
132134
style,
133135
className,
134136
dropdownClassName,
@@ -466,6 +468,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) {
466468
<div className={`${prefixCls}-input`} ref={inputDivRef}>
467469
<input
468470
id={id}
471+
tabIndex={tabIndex}
469472
disabled={disabled}
470473
readOnly={inputReadOnly || !typing}
471474
value={text}

0 commit comments

Comments
 (0)