Skip to content

Commit 42a9d9b

Browse files
committed
refactor(ui-text-input): do not use fancy CSS selectors, Jest crashes on them
1 parent c3100d9 commit 42a9d9b

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

packages/ui-text-input/src/TextInput/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
350350
<span css={styles?.facade}>
351351
{renderBeforeOrAfter ? (
352352
<span css={styles?.layout}>
353+
{beforeElement && <div css={styles?.beforePadding}></div>}
353354
{beforeElement}
354355
{/* The input and content after input should not wrap,
355356
so they're in their own flex container */}

packages/ui-text-input/src/TextInput/props.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ type TextInputStyle = ComponentStyle<
193193
| 'textInput'
194194
| 'facade'
195195
| 'layout'
196+
| 'beforePadding'
196197
| 'afterElement'
197198
| 'requiredInvalid'
198199
| 'inputLayout'

packages/ui-text-input/src/TextInput/styles.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const generateStyle = (
157157
facade: {
158158
label: 'textInput__facade',
159159
position: 'relative',
160-
display: 'flex',
160+
display: 'block',
161161
boxSizing: 'border-box',
162162
border: `${componentTheme.borderWidth} ${componentTheme.borderStyle} ${componentTheme.borderColor}`,
163163
borderRadius: componentTheme.borderRadius,
@@ -188,16 +188,14 @@ const generateStyle = (
188188
label: 'textInput__layout',
189189
...viewBase,
190190
display: 'flex',
191-
flexGrow: 1,
192191
alignItems: 'center',
193192
justifyContent: 'flex-start',
194193
flexDirection: 'row',
195-
// Apply the style if the first child has NOT the inputLayout class
196-
'&:has(> :first-child:not([class$="textInput__inputLayout"]))': {
197-
paddingInlineStart: componentTheme.padding
198-
},
199194
...(!shouldNotWrap && { flexWrap: 'wrap' })
200195
},
196+
beforePadding: {
197+
paddingInlineStart: componentTheme.padding
198+
},
201199
inputLayout: {
202200
label: 'textInput__inputLayout',
203201
flexGrow: 1,
@@ -211,6 +209,7 @@ const generateStyle = (
211209
marginBottom: '-1px',
212210
label: 'textInput__afterElement',
213211
...viewBase,
212+
flexShrink: 0,
214213
paddingInlineEnd: componentTheme.padding,
215214
// we only override the padding once the width is calculated,
216215
// it needs the padding on render

0 commit comments

Comments
 (0)