Skip to content

Commit f74e861

Browse files
authored
fix: clearIcon add tabIndex (#111)
* fix: clearIcon add tabIndex * fix: test update
1 parent 12f3c87 commit f74e861

File tree

6 files changed

+31
-24
lines changed

6 files changed

+31
-24
lines changed

src/BaseInput.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ const BaseInput = React.forwardRef<HolderRef, BaseInputProps>((props, ref) => {
8484
clearIcon = (
8585
<button
8686
type="button"
87+
tabIndex={-1}
8788
onClick={(event) => {
8889
handleReset?.(event);
8990
onClear?.();

src/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import clsx from 'classnames';
2-
import useMergedState from 'rc-util/lib/hooks/useMergedState';
3-
import omit from 'rc-util/lib/omit';
2+
import useMergedState from '@rc-component/util/lib/hooks/useMergedState';
3+
import omit from '@rc-component/util/lib/omit';
44
import React, {
55
forwardRef,
66
useEffect,

tests/BaseInput.test.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,33 @@ describe('BaseInput', () => {
9797
expect(inputEl!.value).toBe('');
9898
});
9999

100-
it('By focus and Space', async () => {
101-
const { container } = render(<Demo />);
100+
// it('By focus and Space', async () => {
101+
// const { container } = render(<Demo />);
102102

103-
const inputEl = container.querySelector('input');
104-
await user.click(inputEl!);
103+
// const inputEl = container.querySelector('input');
104+
// await user.click(inputEl!);
105105

106-
await user.type(inputEl!, 'some text');
107-
expect(inputEl!.value).toBe('some text');
106+
// await user.type(inputEl!, 'some text');
107+
// expect(inputEl!.value).toBe('some text');
108108

109-
await user.tab();
110-
await user.keyboard('[Space]');
111-
expect(inputEl!.value).toBe('');
112-
});
109+
// await user.tab();
110+
// await user.keyboard('[Space]');
111+
// expect(inputEl!.value).toBe('');
112+
// });
113113

114-
it('By focus and Enter', async () => {
115-
const { container } = render(<Demo />);
114+
// it('By focus and Enter', async () => {
115+
// const { container } = render(<Demo />);
116116

117-
const inputEl = container.querySelector('input');
118-
await user.click(inputEl!);
117+
// const inputEl = container.querySelector('input');
118+
// await user.click(inputEl!);
119119

120-
await user.type(inputEl!, 'some text');
121-
expect(inputEl!.value).toBe('some text');
120+
// await user.type(inputEl!, 'some text');
121+
// expect(inputEl!.value).toBe('some text');
122122

123-
await user.tab();
124-
await user.keyboard('[Enter]');
125-
expect(inputEl!.value).toBe('');
126-
});
123+
// await user.tab();
124+
// await user.keyboard('[Enter]');
125+
// expect(inputEl!.value).toBe('');
126+
// });
127127
});
128128

129129
it('should display clearIcon correctly', () => {

tests/__snapshots__/index.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ exports[`Input allowClear should change type when click 1`] = `
117117
>
118118
<button
119119
class="rc-input-clear-icon"
120+
tabindex="-1"
120121
type="button"
121122
>
122123
@@ -141,6 +142,7 @@ exports[`Input allowClear should change type when click 2`] = `
141142
>
142143
<button
143144
class="rc-input-clear-icon rc-input-clear-icon-hidden"
145+
tabindex="-1"
144146
type="button"
145147
>
146148
@@ -165,6 +167,7 @@ exports[`Input allowClear should not show icon if defaultValue is undefined or e
165167
>
166168
<button
167169
class="rc-input-clear-icon rc-input-clear-icon-hidden"
170+
tabindex="-1"
168171
type="button"
169172
>
170173
@@ -189,6 +192,7 @@ exports[`Input allowClear should not show icon if defaultValue is undefined or e
189192
>
190193
<button
191194
class="rc-input-clear-icon rc-input-clear-icon-hidden"
195+
tabindex="-1"
192196
type="button"
193197
>
194198
@@ -213,6 +217,7 @@ exports[`Input allowClear should not show icon if value is undefined or empty st
213217
>
214218
<button
215219
class="rc-input-clear-icon rc-input-clear-icon-hidden"
220+
tabindex="-1"
216221
type="button"
217222
>
218223
@@ -237,6 +242,7 @@ exports[`Input allowClear should not show icon if value is undefined or empty st
237242
>
238243
<button
239244
class="rc-input-clear-icon rc-input-clear-icon-hidden"
245+
tabindex="-1"
240246
type="button"
241247
>
242248

tests/focus.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
2+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
33
import Input from '../src';
44
import { fireEvent, render } from '@testing-library/react';
55

tests/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { fireEvent, render } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
3-
import { spyElementPrototypes } from 'rc-util/lib/test/domHook';
3+
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
44
import React from 'react';
55
import Input from '../src';
66
import type { InputRef } from '../src/interface';

0 commit comments

Comments
 (0)