Skip to content

Commit e4ff5f2

Browse files
committed
CodeReview
1 parent 7710681 commit e4ff5f2

15 files changed

Lines changed: 174 additions & 228 deletions

File tree

.changeset/true-feet-argue.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
##### BaseCodeInput
88

9-
- Добавлен проп `restrictFocus` для включения последовательного ввода:
9+
- Добавлен проп `strictFocus` для включения последовательного ввода:
1010
- при клике на ячейку правее первой пустой — фокус остается на первой
1111
- фокус разрешается только на уже заполненные ячейки и первую пустую ячейку
1212

1313
- Добавлено поведение автоматического фокуса на первый инпут при клике на любое пустое поле
1414

15+
- Улучшена доступность компонента, добавлены `aria-label`.
16+
1517
##### Confirmation
1618

17-
- Добавлена поддержка пропа `restrictFocus` для использования в `CodeInput`
19+
- Добавлена поддержка пропа `strictFocus` для использования в `CodeInput`

packages/calendar/src/__snapshots__/Component.test.tsx.snap

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,19 +2461,6 @@ exports[`Calendar Display tests should match defaultView="years" snapshot 1`] =
24612461
1926
24622462
</span>
24632463
</button>
2464-
<button
2465-
aria-selected="false"
2466-
class="component text size-40 hug size-40 component text component text button default button"
2467-
data-date="-1420070400000"
2468-
tabindex="-1"
2469-
type="button"
2470-
>
2471-
<span
2472-
class="label stretchText"
2473-
>
2474-
1925
2475-
</span>
2476-
</button>
24772464
</div>
24782465
</div>
24792466
</div>

packages/code-input/src/Component.responsive.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { CodeInputDesktop } from './desktop';
66
import { CodeInputMobile } from './mobile';
77
import { type BaseCodeInputProps, type CustomInputRef } from './typings';
88

9-
export type CodeInputProps = Omit<BaseCodeInputProps, 'stylesInput'> & {
9+
export interface CodeInputProps extends Omit<BaseCodeInputProps, 'stylesInput>'> {
1010
/**
1111
* Контрольная точка, с нее начинается desktop версия
1212
* @default 1024

packages/code-input/src/__snapshots__/component.test.tsx.snap

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
exports[`CodeInput Display tests should display correctly 1`] = `
44
<div>
55
<div
6+
aria-label="Код подтверждения"
67
class="component"
8+
role="group"
79
>
810
<div
911
class=""
1012
>
1113
<input
14+
aria-label="Код 1 из 4"
1215
autocomplete="one-time-code"
1316
class="input component"
1417
data-code-input-index="0"
@@ -17,6 +20,7 @@ exports[`CodeInput Display tests should display correctly 1`] = `
1720
value=""
1821
/>
1922
<input
23+
aria-label="Код 2 из 4"
2024
autocomplete=""
2125
class="input component"
2226
data-code-input-index="1"
@@ -25,6 +29,7 @@ exports[`CodeInput Display tests should display correctly 1`] = `
2529
value=""
2630
/>
2731
<input
32+
aria-label="Код 3 из 4"
2833
autocomplete=""
2934
class="input component"
3035
data-code-input-index="2"
@@ -33,6 +38,7 @@ exports[`CodeInput Display tests should display correctly 1`] = `
3338
value=""
3439
/>
3540
<input
41+
aria-label="Код 4 из 4"
3642
autocomplete=""
3743
class="input component"
3844
data-code-input-index="3"
@@ -48,12 +54,15 @@ exports[`CodeInput Display tests should display correctly 1`] = `
4854
exports[`CodeInput Display tests should display correctly with error 1`] = `
4955
<div>
5056
<div
57+
aria-label="Код подтверждения"
5158
class="component"
59+
role="group"
5260
>
5361
<div
5462
class="shake"
5563
>
5664
<input
65+
aria-label="Код 1 из 4"
5766
autocomplete="one-time-code"
5867
class="input component hasError"
5968
data-code-input-index="0"
@@ -62,6 +71,7 @@ exports[`CodeInput Display tests should display correctly with error 1`] = `
6271
value=""
6372
/>
6473
<input
74+
aria-label="Код 2 из 4"
6575
autocomplete=""
6676
class="input component hasError"
6777
data-code-input-index="1"
@@ -70,6 +80,7 @@ exports[`CodeInput Display tests should display correctly with error 1`] = `
7080
value=""
7181
/>
7282
<input
83+
aria-label="Код 3 из 4"
7384
autocomplete=""
7485
class="input component hasError"
7586
data-code-input-index="2"
@@ -78,6 +89,7 @@ exports[`CodeInput Display tests should display correctly with error 1`] = `
7889
value=""
7990
/>
8091
<input
92+
aria-label="Код 4 из 4"
8193
autocomplete=""
8294
class="input component hasError"
8395
data-code-input-index="3"

packages/code-input/src/component.test.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,14 @@ describe('CodeInput', () => {
229229
let container: HTMLElement;
230230
let inputs: NodeListOf<HTMLInputElement>;
231231

232-
type TFocusCase = {
232+
type FocusCase = {
233233
name: string;
234234
setup: () => Promise<void>;
235235
clickIndex: number;
236236
expectedFocusIndex: number;
237237
};
238238

239-
const focusCases: Array<TFocusCase> = [
239+
const focusCases: Array<FocusCase> = [
240240
{
241241
name: 'should focus first input when clicking on any empty input',
242242
setup: async () => {},
@@ -310,7 +310,7 @@ describe('CodeInput', () => {
310310
});
311311
});
312312

313-
describe('restrictFocus', () => {
313+
describe('strictFocus', () => {
314314
let container: HTMLElement;
315315
let inputs: NodeListOf<HTMLInputElement>;
316316

@@ -352,7 +352,7 @@ describe('CodeInput', () => {
352352
];
353353

354354
beforeEach(() => {
355-
({ container } = render(<CodeInput restrictFocus={true} />));
355+
({ container } = render(<CodeInput strictFocus />));
356356
inputs = getInputs(container);
357357
});
358358

@@ -366,7 +366,7 @@ describe('CodeInput', () => {
366366
},
367367
);
368368

369-
it('ArrowRight does not move focus when restrictFocus is false and first value is empty', async () => {
369+
it('ArrowRight does not move focus when strictFocus is false and first value is empty', async () => {
370370
({ container } = render(<CodeInput />));
371371
inputs = getInputs(container);
372372

@@ -415,7 +415,7 @@ describe('CodeInput', () => {
415415
expectedFocus: 0,
416416
},
417417
])('$name', async ({ fields, preset, clickIndex, expectedFocus }) => {
418-
({ container } = render(<CodeInput fields={fields} restrictFocus={true} />));
418+
({ container } = render(<CodeInput fields={fields} strictFocus />));
419419
inputs = getInputs(container);
420420

421421
await fillByArray(container, preset);
@@ -427,7 +427,7 @@ describe('CodeInput', () => {
427427
});
428428

429429
it('ArrowRight focuses first empty when restricted', async () => {
430-
({ container } = render(<CodeInput fields={4} restrictFocus={true} />));
430+
({ container } = render(<CodeInput fields={4} strictFocus />));
431431
inputs = getInputs(container);
432432

433433
await fillByArray(container, ['1', undefined, undefined, undefined]);
@@ -440,7 +440,7 @@ describe('CodeInput', () => {
440440

441441
describe('deletion restrictions', () => {
442442
it('click on any filled cell when fully filled keeps that cell focused', async () => {
443-
({ container } = render(<CodeInput fields={4} restrictFocus={true} />));
443+
({ container } = render(<CodeInput fields={4} strictFocus />));
444444
inputs = getInputs(container);
445445

446446
await fillByArray(container, ['1', '2', '3', '4']);
@@ -452,7 +452,7 @@ describe('CodeInput', () => {
452452
});
453453

454454
it('after deleting last, clicks on filled cells keep their focus and empty fields redirect', async () => {
455-
({ container } = render(<CodeInput fields={5} restrictFocus={true} />));
455+
({ container } = render(<CodeInput fields={5} strictFocus />));
456456
inputs = getInputs(container);
457457

458458
await fillByArray(container, ['1', '2', '3', '4', '5']);

0 commit comments

Comments
 (0)