Skip to content

Commit b1dc956

Browse files
authored
Fix InputChips/InputText layout issues (#1301)
1 parent d825e32 commit b1dc956

File tree

11 files changed

+249
-136
lines changed

11 files changed

+249
-136
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818

19+
- `InputChips` and `SelectMulti` overflow when a fixed height is used
20+
- `InputChips` and `SelectMulti` long values breaking out of the input
21+
- `InputSearch`, `Select`, `InputChips` and `SelectMulti` x button not clickable with `autoResize` and a max-width reached
1922
- `Select`/`SelectMulti` list closing when trying to scroll by dragging the scrollbar
2023
- `SelectMulti` list height now adjusts as needed when chips are added
2124
- `Select` getting text highlighted in a focus trap when not filterable

packages/components/src/Form/Fields/Field.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
import React, { FunctionComponent, ReactNode, useContext } from 'react'
28+
import { width } from '@looker/design-tokens'
2829
import styled, { css } from 'styled-components'
2930
import { ResponsiveValue, TLengthStyledSystem } from 'styled-system'
3031
import omit from 'lodash/omit'
@@ -160,7 +161,10 @@ FieldDetail.defaultProps = {
160161
fontSize: 'xsmall',
161162
}
162163

163-
const InputArea = styled.div``
164+
const InputArea = styled.div`
165+
/* Workaround for Chip's truncate styling breaking flexbox layout in FieldChips */
166+
min-width: 0;
167+
`
164168
const MessageArea = styled.div``
165169

166170
const fieldLabelCSS = (inline?: boolean) =>
@@ -188,8 +192,8 @@ export const Field = styled(FieldLayout)<FieldPropsInternal>`
188192
grid-template-columns: ${({ inline }) => (inline ? '150px 1fr' : undefined)};
189193
height: fit-content;
190194
justify-content: space-between;
191-
width: ${({ autoResize, width }) =>
192-
width || autoResize ? 'fit-content' : '100%'};
195+
width: ${({ autoResize }) => (autoResize ? 'fit-content' : '100%')};
196+
${width}
193197
194198
${InputArea} {
195199
align-items: center;

packages/components/src/Form/Fields/FieldText/__snapshots__/FieldText.test.tsx.snap

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

33
exports[`A FieldText with default label 1`] = `
4-
.c4 {
4+
.c5 {
55
-webkit-align-items: center;
66
-webkit-box-align: center;
77
-ms-flex-align: center;
@@ -26,17 +26,17 @@ exports[`A FieldText with default label 1`] = `
2626
font-size: 0.875rem;
2727
}
2828
29-
.c4 .c6 {
29+
.c5 .c7 {
3030
height: 100%;
3131
max-width: 100%;
3232
width: 100%;
3333
}
3434
35-
.c4 .c6 span {
35+
.c5 .c7 span {
3636
padding: 0 0.5rem;
3737
}
3838
39-
.c4 input {
39+
.c5 input {
4040
background: transparent;
4141
border: none;
4242
caret-color: #262D33;
@@ -52,37 +52,37 @@ exports[`A FieldText with default label 1`] = `
5252
padding: 0 0.5rem;
5353
}
5454
55-
.c4 input::-webkit-search-decoration,
56-
.c4 input::-webkit-search-cancel-button,
57-
.c4 input::-webkit-search-results-button,
58-
.c4 input::-webkit-search-results-decoration {
55+
.c5 input::-webkit-search-decoration,
56+
.c5 input::-webkit-search-cancel-button,
57+
.c5 input::-webkit-search-results-button,
58+
.c5 input::-webkit-search-results-decoration {
5959
-webkit-appearance: none;
6060
-moz-appearance: none;
6161
appearance: none;
6262
}
6363
64-
.c4 input::-webkit-input-placeholder {
64+
.c5 input::-webkit-input-placeholder {
6565
color: #939BA5;
6666
}
6767
68-
.c4 input::-moz-placeholder {
68+
.c5 input::-moz-placeholder {
6969
color: #939BA5;
7070
}
7171
72-
.c4 input:-ms-input-placeholder {
72+
.c5 input:-ms-input-placeholder {
7373
color: #939BA5;
7474
}
7575
76-
.c4 input::placeholder {
76+
.c5 input::placeholder {
7777
color: #939BA5;
7878
}
7979
80-
.c4:hover {
80+
.c5:hover {
8181
border-color: #C1C6CC;
8282
}
8383
84-
.c4:focus,
85-
.c4:focus-within {
84+
.c5:focus,
85+
.c5:focus-within {
8686
border-color: #9785F2;
8787
box-shadow: 0 0 0 2px #E8E5FF;
8888
outline: none;
@@ -94,6 +94,10 @@ exports[`A FieldText with default label 1`] = `
9494
font-weight: 600;
9595
}
9696
97+
.c4 {
98+
min-width: 0;
99+
}
100+
97101
.c0 {
98102
-webkit-align-items: left;
99103
-webkit-box-align: left;
@@ -119,7 +123,7 @@ exports[`A FieldText with default label 1`] = `
119123
grid-area: input;
120124
}
121125
122-
.c0 .c5 {
126+
.c0 .c6 {
123127
grid-area: messages;
124128
}
125129
@@ -129,13 +133,13 @@ exports[`A FieldText with default label 1`] = `
129133
padding-bottom: 0.5rem;
130134
}
131135
132-
.c0 .c8 {
136+
.c0 .c9 {
133137
grid-area: detail;
134138
justify-self: end;
135139
padding-left: 0.75rem;
136140
}
137141
138-
.c0 .c7 {
142+
.c0 .c8 {
139143
margin-top: 0.5rem;
140144
}
141145
@@ -150,10 +154,10 @@ exports[`A FieldText with default label 1`] = `
150154
👍
151155
</label>
152156
<div
153-
className="c3 "
157+
className="c3 c4"
154158
>
155159
<div
156-
className="c4 "
160+
className="c5 "
157161
onMouseDown={[Function]}
158162
>
159163
<input
@@ -164,14 +168,14 @@ exports[`A FieldText with default label 1`] = `
164168
</div>
165169
</div>
166170
<div
167-
className="c5 "
171+
className="c6 "
168172
id="FieldTextID-describedby"
169173
/>
170174
</div>
171175
`;
172176

173177
exports[`A FieldText with label inline 1`] = `
174-
.c4 {
178+
.c5 {
175179
-webkit-align-items: center;
176180
-webkit-box-align: center;
177181
-ms-flex-align: center;
@@ -196,17 +200,17 @@ exports[`A FieldText with label inline 1`] = `
196200
font-size: 0.875rem;
197201
}
198202
199-
.c4 .c7 {
203+
.c5 .c8 {
200204
height: 100%;
201205
max-width: 100%;
202206
width: 100%;
203207
}
204208
205-
.c4 .c7 span {
209+
.c5 .c8 span {
206210
padding: 0 0.5rem;
207211
}
208212
209-
.c4 input {
213+
.c5 input {
210214
background: transparent;
211215
border: none;
212216
caret-color: #262D33;
@@ -222,37 +226,37 @@ exports[`A FieldText with label inline 1`] = `
222226
padding: 0 0.5rem;
223227
}
224228
225-
.c4 input::-webkit-search-decoration,
226-
.c4 input::-webkit-search-cancel-button,
227-
.c4 input::-webkit-search-results-button,
228-
.c4 input::-webkit-search-results-decoration {
229+
.c5 input::-webkit-search-decoration,
230+
.c5 input::-webkit-search-cancel-button,
231+
.c5 input::-webkit-search-results-button,
232+
.c5 input::-webkit-search-results-decoration {
229233
-webkit-appearance: none;
230234
-moz-appearance: none;
231235
appearance: none;
232236
}
233237
234-
.c4 input::-webkit-input-placeholder {
238+
.c5 input::-webkit-input-placeholder {
235239
color: #939BA5;
236240
}
237241
238-
.c4 input::-moz-placeholder {
242+
.c5 input::-moz-placeholder {
239243
color: #939BA5;
240244
}
241245
242-
.c4 input:-ms-input-placeholder {
246+
.c5 input:-ms-input-placeholder {
243247
color: #939BA5;
244248
}
245249
246-
.c4 input::placeholder {
250+
.c5 input::placeholder {
247251
color: #939BA5;
248252
}
249253
250-
.c4:hover {
254+
.c5:hover {
251255
border-color: #C1C6CC;
252256
}
253257
254-
.c4:focus,
255-
.c4:focus-within {
258+
.c5:focus,
259+
.c5:focus-within {
256260
border-color: #9785F2;
257261
box-shadow: 0 0 0 2px #E8E5FF;
258262
outline: none;
@@ -264,19 +268,23 @@ exports[`A FieldText with label inline 1`] = `
264268
font-weight: 600;
265269
}
266270
267-
.c6 .c3 {
271+
.c4 {
272+
min-width: 0;
273+
}
274+
275+
.c7 .c3 {
268276
-webkit-align-items: center;
269277
-webkit-box-align: center;
270278
-ms-flex-align: center;
271279
align-items: center;
272280
grid-area: input;
273281
}
274282
275-
.c6 .c5 {
283+
.c7 .c6 {
276284
grid-area: messages;
277285
}
278286
279-
.c6 > .c1 {
287+
.c7 > .c1 {
280288
grid-area: label;
281289
line-height: 1rem;
282290
padding-bottom: 0.5rem;
@@ -308,7 +316,7 @@ exports[`A FieldText with label inline 1`] = `
308316
grid-area: input;
309317
}
310318
311-
.c0 .c5 {
319+
.c0 .c6 {
312320
grid-area: messages;
313321
}
314322
@@ -321,7 +329,7 @@ exports[`A FieldText with label inline 1`] = `
321329
text-align: right;
322330
}
323331
324-
.c0 .c9 {
332+
.c0 .c10 {
325333
grid-area: detail;
326334
justify-self: end;
327335
padding-left: 0.75rem;
@@ -330,7 +338,7 @@ exports[`A FieldText with label inline 1`] = `
330338
align-self: center;
331339
}
332340
333-
.c0 .c8 {
341+
.c0 .c9 {
334342
margin-top: 0.5rem;
335343
}
336344
@@ -345,10 +353,10 @@ exports[`A FieldText with label inline 1`] = `
345353
👍
346354
</label>
347355
<div
348-
className="c3 "
356+
className="c3 c4"
349357
>
350358
<div
351-
className="c4 "
359+
className="c5 "
352360
onMouseDown={[Function]}
353361
>
354362
<input
@@ -359,7 +367,7 @@ exports[`A FieldText with label inline 1`] = `
359367
</div>
360368
</div>
361369
<div
362-
className="c5 "
370+
className="c6 "
363371
id="FieldTextID-describedby"
364372
/>
365373
</div>

0 commit comments

Comments
 (0)