Skip to content

Commit 1a2bb05

Browse files
committed
add InputField overflow PW tests
1 parent c2ba481 commit 1a2bb05

7 files changed

Lines changed: 185 additions & 49 deletions

File tree

src/components/Field/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ export const Field = forwardRef<HTMLDivElement, FieldProps>(
248248
...restFieldProps
249249
} = props;
250250
const [defaultID] = useState(uid());
251-
const fieldContainerProps = { className, style, ...restFieldProps } as Record<string, any>;
251+
const fieldContainerProps = { className, style, ...restFieldProps } as Record<string, unknown>;
252252

253253
const labelProps = { htmlFor: id ?? defaultID, required, disabled };
254254

src/components/Label/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import styled, { css } from 'styled-components';
1+
import type { css } from 'styled-components';
2+
import styled from 'styled-components';
23
import { typography } from '#src/components/Typography';
34

45
export const MainLabel = styled.div<{ $cssMixin?: ReturnType<typeof css> }>`

src/components/form/DateField/__snapshots__/DateField.test.tsx.snap

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`DateField should render component 1`] = `
4-
.c1 {
4+
.c2 {
55
position: relative;
66
display: flex;
77
align-items: stretch;
@@ -10,46 +10,51 @@ exports[`DateField should render component 1`] = `
1010
pointer-events: all;
1111
}
1212
13-
.c2 {
13+
.c3 {
1414
height: 40px;
1515
}
1616
17+
.c1 {
18+
min-width: 0;
19+
}
20+
1721
.c0 {
1822
display: flex;
1923
overflow: hidden;
2024
flex-direction: column;
2125
}
2226
23-
.c11 {
27+
.c12 {
2428
display: flex;
2529
justify-content: space-between;
30+
min-width: 0;
2631
}
2732
28-
.c10 {
33+
.c11 {
2934
cursor: pointer;
3035
}
3136
32-
.c10 *[fill^='#'] {
37+
.c11 *[fill^='#'] {
3338
fill: var(--admiral-color-Neutral_Neutral50, #74767B);
3439
}
3540
36-
[data-loading] .c10.c10.c10 {
41+
[data-loading] .c11.c11.c11 {
3742
pointer-events: none;
3843
}
3944
40-
[disabled] .c10.c10.c10 {
45+
[disabled] .c11.c11.c11 {
4146
pointer-events: none;
4247
}
4348
44-
[disabled] .c10.c10.c10 *[fill^='#'] {
49+
[disabled] .c11.c11.c11 *[fill^='#'] {
4550
fill: var(--admiral-color-Neutral_Neutral30, #B2B5B8);
4651
}
4752
48-
.c10:hover *[fill^='#'] {
53+
.c11:hover *[fill^='#'] {
4954
fill: var(--admiral-color-Primary_Primary70, #0046E2);
5055
}
5156
52-
.c7 {
57+
.c8 {
5358
position: absolute;
5459
top: 0;
5560
bottom: 0;
@@ -64,7 +69,7 @@ exports[`DateField should render component 1`] = `
6469
border: 1px solid var(--admiral-color-Neutral_Neutral40, #9EA0A4);
6570
}
6671
67-
.c5 {
72+
.c6 {
6873
outline: none;
6974
appearance: none;
7075
border-radius: inherit;
@@ -87,96 +92,96 @@ exports[`DateField should render component 1`] = `
8792
padding-left: 16px;
8893
}
8994
90-
.c5.c5.c5:disabled {
95+
.c6.c6.c6:disabled {
9196
color: var(--admiral-color-Neutral_Neutral30, #B2B5B8);
9297
}
9398
94-
.c5::placeholder {
99+
.c6::placeholder {
95100
color: var(--admiral-color-Neutral_Neutral50, #74767B);
96101
}
97102
98-
.c5:disabled::placeholder {
103+
.c6:disabled::placeholder {
99104
color: var(--admiral-color-Neutral_Neutral30, #B2B5B8);
100105
}
101106
102-
[data-disable-copying] .c5 {
107+
[data-disable-copying] .c6 {
103108
user-select: none;
104109
}
105110
106-
[data-disable-copying] .c5::selection {
111+
[data-disable-copying] .c6::selection {
107112
background-color: transparent;
108113
}
109114
110-
.c5.c5.c5:user-invalid+.c6 {
115+
.c6.c6.c6:user-invalid+.c7 {
111116
border: 1px solid var(--admiral-color-Error_Error60Main, #D92020);
112117
}
113118
114-
.c5.c5.c5:user-invalid:hover:not(:disabled)+.c6 {
119+
.c6.c6.c6:user-invalid:hover:not(:disabled)+.c7 {
115120
border: 1px solid var(--admiral-color-Error_Error70, #BA1717);
116121
}
117122
118-
.c5.c5.c5:user-invalid:focus:not(:disabled)+.c6 {
123+
.c6.c6.c6:user-invalid:focus:not(:disabled)+.c7 {
119124
border: 2px solid var(--admiral-color-Error_Error60Main, #D92020);
120125
}
121126
122-
[data-read-only] .c5.c5.c5,
123-
.c5.c5.c5:disabled {
127+
[data-read-only] .c6.c6.c6,
128+
.c6.c6.c6:disabled {
124129
background-color: var(--admiral-color-Neutral_Neutral10, #EAEBEC);
125130
border-color: transparent;
126131
}
127132
128-
[data-loading] .c5.c5.c5,
129-
.c5.c5.c5:disabled {
133+
[data-loading] .c6.c6.c6,
134+
.c6.c6.c6:disabled {
130135
cursor: not-allowed;
131136
pointer-events: none;
132137
}
133138
134-
.c5 ::-ms-clear,
135-
.c5 ::-ms-reveal {
139+
.c6 ::-ms-clear,
140+
.c6 ::-ms-reveal {
136141
display: none;
137142
}
138143
139-
.c8 {
144+
.c9 {
140145
position: absolute;
141146
top: 0;
142147
bottom: 0;
143148
display: flex;
144149
align-items: center;
145150
}
146151
147-
.c8 svg {
152+
.c9 svg {
148153
border-radius: var(--admiral-border-radius-Medium, 4px);
149154
display: block;
150155
width: 24px;
151156
}
152157
153-
.c8 svg:focus {
158+
.c9 svg:focus {
154159
outline: none;
155160
}
156161
157-
.c8 svg:focus-visible {
162+
.c9 svg:focus-visible {
158163
outline-offset: 2px;
159164
outline: var(--admiral-color-Primary_Primary60Main, #0062FF) solid 2px;
160165
}
161166
162-
.c9 {
167+
.c10 {
163168
right: 0;
164169
padding-right: 16px;
165170
}
166171
167-
.c9>*:not(:first-child) {
172+
.c10>*:not(:first-child) {
168173
margin-left: 8px;
169174
}
170175
171-
.c3:focus-within:not(:disabled)>.c6 {
176+
.c4:focus-within:not(:disabled)>.c7 {
172177
border: 2px solid var(--admiral-color-Primary_Primary60Main, #0062FF);
173178
}
174179
175-
.c3:hover:not(:focus-within)>.c6 {
180+
.c4:hover:not(:focus-within)>.c7 {
176181
border-color: var(--admiral-color-Neutral_Neutral60, #67696D);
177182
}
178183
179-
.c4 {
184+
.c5 {
180185
min-width: 150px;
181186
}
182187
@@ -186,30 +191,30 @@ exports[`DateField should render component 1`] = `
186191
data-field-id="some static snapshot id"
187192
>
188193
<div
189-
class=""
194+
class="c1"
190195
>
191196
<div
192-
class="c1 c2 c3 c4"
197+
class="c2 c3 c4 c5"
193198
>
194199
<input
195-
class="c5 text-input-native-input"
200+
class="c6 text-input-native-input"
196201
data-testid="my test input"
197202
id="some static snapshot id"
198203
/>
199204
<div
200-
class="c6 c7"
205+
class="c7 c8"
201206
/>
202207
<div
203-
class="c8 c9"
208+
class="c9 c10"
204209
>
205210
<div
206-
class="c10"
211+
class="c11"
207212
tabindex="0"
208213
/>
209214
</div>
210215
</div>
211216
<div
212-
class="c11"
217+
class="c12"
213218
/>
214219
</div>
215220
</div>

src/components/form/InputField/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export const InputField = React.forwardRef<HTMLInputElement, InputFieldProps>((p
5555
disableAdditionalLabelTooltip,
5656
'data-field-id': id,
5757
'data-field-name': restProps.name,
58-
} as Record<string, any>;
58+
} as Record<string, unknown>;
5959

6060
passFormFieldDataAttributes(restProps, fieldContainerProps);
6161
passFormFieldContainerDataAttributes(restProps, fieldContainerProps);

src/components/input/TimePicker/TimePicker.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ interface CustomTimePickerProps extends TimePickerProps {
99
}
1010

1111
const TimePickerComponent = (props: CustomTimePickerProps) => {
12+
const { testId, ...timePickerProps } = props;
1213
return (
1314
<ThemeProvider theme={LIGHT_THEME}>
14-
<TimePicker {...props} data-testid={props.testId} />
15+
<TimePicker {...timePickerProps} data-testid={testId} />
1516
</ThemeProvider>
1617
);
1718
};

src/components/input/TimePicker/index.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,16 @@ export const TimePicker = React.forwardRef<HTMLInputElement, TimePickerProps>(
183183
inputLinePropsConfig = () => ({}),
184184
clearInputIconButtonPropsConfig = () => ({}),
185185
timeInputIconButtonPropsConfig = () => ({}),
186+
handleInput: handleInputProp,
187+
value: valueProp,
188+
defaultValue: defaultValueProp,
186189
...props
187190
},
188191
ref,
189192
) => {
190-
const handleInput = props.handleInput || defaultTimePickerHandle;
191-
const [innerValueState, setInnerValueState] = useState(String(props.defaultValue ?? ''));
192-
const innerValue = String(props.value ?? innerValueState);
193+
const handleInput = handleInputProp || defaultTimePickerHandle;
194+
const [innerValueState, setInnerValueState] = useState(String(defaultValueProp ?? ''));
195+
const innerValue = String(valueProp ?? innerValueState);
193196
const [activeOption, setActiveOption] = React.useState<string | undefined>('');
194197
const inputContainerRef = containerRef || useRef<HTMLDivElement>(null);
195198
const inputRef = useRef<HTMLInputElement>(null);
@@ -322,7 +325,6 @@ export const TimePicker = React.forwardRef<HTMLInputElement, TimePickerProps>(
322325
if (!props.readOnly && displayClearIcon && !!innerValue) {
323326
const clearInputIconButtonProps = {
324327
icon: CloseOutlineSvg,
325-
key: 'clear-icon',
326328
onMouseDown: (e: React.MouseEvent<SVGSVGElement, MouseEvent>) => {
327329
// запрет на перемещение фокуса при клике по иконке
328330
e.preventDefault();
@@ -337,6 +339,7 @@ export const TimePicker = React.forwardRef<HTMLInputElement, TimePickerProps>(
337339

338340
iconArray.unshift(
339341
<InputIconButton
342+
key="clear-icon"
340343
{...clearInputIconButtonProps}
341344
{...clearInputIconButtonPropsConfig(clearInputIconButtonProps)}
342345
/>,

0 commit comments

Comments
 (0)