@instructure/ui-text-input 10.7.0 → 10.7.1-snapshot-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [10.7.1-snapshot-0](https://github.com/instructure/instructure-ui/compare/v10.7.0...v10.7.1-snapshot-0) (2024-12-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-select,ui-text-input:** fix long before elements overflowing in TextInput, Select, SimpleSelect ([ee9cafd](https://github.com/instructure/instructure-ui/commit/ee9cafdd027b9a1caaa0791d1b6dc4f8401c87e7))
12
+
13
+
14
+
15
+
16
+
6
17
  # [10.7.0](https://github.com/instructure/instructure-ui/compare/v10.6.1...v10.7.0) (2024-12-03)
7
18
 
8
19
 
@@ -48,7 +48,6 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
48
48
  super(props);
49
49
  this.ref = null;
50
50
  this._input = null;
51
- this._beforeElement = null;
52
51
  this._afterElement = null;
53
52
  this._defaultId = void 0;
54
53
  this._messagesId = void 0;
@@ -64,14 +63,13 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
64
63
  const interaction = this.interaction;
65
64
  const _this$state = this.state,
66
65
  hasFocus = _this$state.hasFocus,
67
- beforeElementHasWidth = _this$state.beforeElementHasWidth,
68
66
  afterElementHasWidth = _this$state.afterElementHasWidth;
69
67
  return {
70
68
  disabled: interaction === 'disabled',
71
69
  invalid: this.invalid,
72
70
  focused: hasFocus,
73
- beforeElementHasWidth,
74
- afterElementHasWidth
71
+ afterElementHasWidth: afterElementHasWidth,
72
+ beforeElementExists: this.props.renderBeforeInput != void 0
75
73
  };
76
74
  };
77
75
  this.handleInputRef = node => {
@@ -103,7 +101,6 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
103
101
  };
104
102
  this.state = {
105
103
  hasFocus: false,
106
- beforeElementHasWidth: void 0,
107
104
  afterElementHasWidth: void 0
108
105
  };
109
106
  this._defaultId = props.deterministicId();
@@ -114,7 +111,6 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
114
111
  if (this._input) {
115
112
  this._focusListener = addEventListener(this._input, 'focus', this.handleFocus);
116
113
  this.setState({
117
- beforeElementHasWidth: this.getElementHasWidth(this._beforeElement),
118
114
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
119
115
  });
120
116
  }
@@ -127,11 +123,6 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
127
123
  }
128
124
  componentDidUpdate(prevProps) {
129
125
  var _this$props$makeStyle2, _this$props2;
130
- if (prevProps.renderBeforeInput !== this.props.renderBeforeInput) {
131
- this.setState({
132
- beforeElementHasWidth: this.getElementHasWidth(this._beforeElement)
133
- });
134
- }
135
126
  if (prevProps.renderAfterInput !== this.props.renderAfterInput) {
136
127
  this.setState({
137
128
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
@@ -265,25 +256,16 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
265
256
  elementRef: this.handleRef
266
257
  }, jsx("span", {
267
258
  css: styles === null || styles === void 0 ? void 0 : styles.facade
268
- }, renderBeforeOrAfter ? jsx("div", null, jsx("span", {
259
+ }, renderBeforeOrAfter ? jsx("span", {
269
260
  css: styles === null || styles === void 0 ? void 0 : styles.layout
270
- }, beforeElement && jsx("span", {
271
- css: styles === null || styles === void 0 ? void 0 : styles.beforeElement,
272
- ref: e => {
273
- this._beforeElement = e;
274
- }
275
- }, beforeElement), jsx("span", {
276
- css: styles === null || styles === void 0 ? void 0 : styles.innerWrapper
277
- }, jsx("span", {
261
+ }, beforeElement, jsx("span", {
278
262
  css: styles === null || styles === void 0 ? void 0 : styles.inputLayout
279
- }, jsx("span", {
280
- css: styles === null || styles === void 0 ? void 0 : styles.innerWrapper
281
- }, this.renderInput()), afterElement && jsx("span", {
263
+ }, this.renderInput(), afterElement && jsx("span", {
282
264
  css: styles === null || styles === void 0 ? void 0 : styles.afterElement,
283
265
  ref: e => {
284
266
  this._afterElement = e;
285
267
  }
286
- }, afterElement))))) : (/* If no prepended or appended content, don't render Flex layout */
268
+ }, afterElement))) : (/* If no prepended or appended content, don't render Flex layout */
287
269
  this.renderInput())));
288
270
  }
289
271
  }, _TextInput.displayName = "TextInput", _TextInput.componentId = 'TextInput', _TextInput.allowedProps = allowedProps, _TextInput.propTypes = propTypes, _TextInput.defaultProps = {
@@ -39,8 +39,8 @@ const generateStyle = (componentTheme, props, state) => {
39
39
  const disabled = state.disabled,
40
40
  invalid = state.invalid,
41
41
  focused = state.focused,
42
- beforeElementHasWidth = state.beforeElementHasWidth,
43
- afterElementHasWidth = state.afterElementHasWidth;
42
+ afterElementHasWidth = state.afterElementHasWidth,
43
+ beforeElementExists = state.beforeElementExists;
44
44
  const sizeVariants = {
45
45
  small: {
46
46
  fontSize: componentTheme.smallFontSize,
@@ -81,11 +81,11 @@ const generateStyle = (componentTheme, props, state) => {
81
81
  '&::-ms-clear': {
82
82
  display: 'none'
83
83
  },
84
+ width: '100%',
84
85
  WebkitFontSmoothing: 'antialiased',
85
86
  MozOsxFontSmoothing: 'grayscale',
86
87
  appearance: 'none',
87
88
  margin: 0,
88
- width: '100%',
89
89
  display: 'block',
90
90
  boxSizing: 'border-box',
91
91
  outline: 'none',
@@ -122,10 +122,6 @@ const generateStyle = (componentTheme, props, state) => {
122
122
  justifyContent: 'flex-start',
123
123
  flexDirection: 'row'
124
124
  };
125
- const flexItemBase = {
126
- ...viewBase,
127
- flexShrink: 0
128
- };
129
125
  return {
130
126
  requiredInvalid: {
131
127
  color: componentTheme.requiredInvalidColor
@@ -167,32 +163,21 @@ const generateStyle = (componentTheme, props, state) => {
167
163
  },
168
164
  layout: {
169
165
  label: 'textInput__layout',
170
- ...flexBase,
166
+ ...viewBase,
167
+ display: 'flex',
168
+ alignItems: 'center',
169
+ justifyContent: 'flex-start',
170
+ flexDirection: 'row',
171
171
  ...(!shouldNotWrap && {
172
172
  flexWrap: 'wrap'
173
+ }),
174
+ ...(beforeElementExists && {
175
+ paddingInlineStart: componentTheme.padding
173
176
  })
174
177
  },
175
- beforeElement: {
176
- display: 'inline-flex',
177
- alignItems: 'center',
178
- label: 'textInput__beforeElement',
179
- ...flexItemBase,
180
- paddingInlineStart: componentTheme.padding,
181
- // we only override the padding once the width is calculated,
182
- // it needs the padding on render
183
- ...(beforeElementHasWidth === false && {
184
- paddingInlineStart: 0
185
- })
186
- },
187
- innerWrapper: {
188
- label: 'textInput__innerWrapper',
189
- ...flexItemBase,
190
- minWidth: '0.0625rem',
191
- flexShrink: 1,
192
- flexGrow: 1
193
- },
194
178
  inputLayout: {
195
179
  label: 'textInput__inputLayout',
180
+ flexGrow: 1,
196
181
  ...flexBase
197
182
  },
198
183
  afterElement: {
@@ -202,7 +187,8 @@ const generateStyle = (componentTheme, props, state) => {
202
187
  marginTop: '-1px',
203
188
  marginBottom: '-1px',
204
189
  label: 'textInput__afterElement',
205
- ...flexItemBase,
190
+ ...viewBase,
191
+ flexShrink: 0,
206
192
  paddingInlineEnd: componentTheme.padding,
207
193
  // we only override the padding once the width is calculated,
208
194
  // it needs the padding on render
@@ -58,7 +58,6 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
58
58
  super(props);
59
59
  this.ref = null;
60
60
  this._input = null;
61
- this._beforeElement = null;
62
61
  this._afterElement = null;
63
62
  this._defaultId = void 0;
64
63
  this._messagesId = void 0;
@@ -74,14 +73,13 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
74
73
  const interaction = this.interaction;
75
74
  const _this$state = this.state,
76
75
  hasFocus = _this$state.hasFocus,
77
- beforeElementHasWidth = _this$state.beforeElementHasWidth,
78
76
  afterElementHasWidth = _this$state.afterElementHasWidth;
79
77
  return {
80
78
  disabled: interaction === 'disabled',
81
79
  invalid: this.invalid,
82
80
  focused: hasFocus,
83
- beforeElementHasWidth,
84
- afterElementHasWidth
81
+ afterElementHasWidth: afterElementHasWidth,
82
+ beforeElementExists: this.props.renderBeforeInput != void 0
85
83
  };
86
84
  };
87
85
  this.handleInputRef = node => {
@@ -113,7 +111,6 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
113
111
  };
114
112
  this.state = {
115
113
  hasFocus: false,
116
- beforeElementHasWidth: void 0,
117
114
  afterElementHasWidth: void 0
118
115
  };
119
116
  this._defaultId = props.deterministicId();
@@ -124,7 +121,6 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
124
121
  if (this._input) {
125
122
  this._focusListener = (0, _addEventListener.addEventListener)(this._input, 'focus', this.handleFocus);
126
123
  this.setState({
127
- beforeElementHasWidth: this.getElementHasWidth(this._beforeElement),
128
124
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
129
125
  });
130
126
  }
@@ -137,11 +133,6 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
137
133
  }
138
134
  componentDidUpdate(prevProps) {
139
135
  var _this$props$makeStyle2, _this$props2;
140
- if (prevProps.renderBeforeInput !== this.props.renderBeforeInput) {
141
- this.setState({
142
- beforeElementHasWidth: this.getElementHasWidth(this._beforeElement)
143
- });
144
- }
145
136
  if (prevProps.renderAfterInput !== this.props.renderAfterInput) {
146
137
  this.setState({
147
138
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
@@ -275,25 +266,16 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
275
266
  elementRef: this.handleRef
276
267
  }, (0, _emotion.jsx)("span", {
277
268
  css: styles === null || styles === void 0 ? void 0 : styles.facade
278
- }, renderBeforeOrAfter ? (0, _emotion.jsx)("div", null, (0, _emotion.jsx)("span", {
269
+ }, renderBeforeOrAfter ? (0, _emotion.jsx)("span", {
279
270
  css: styles === null || styles === void 0 ? void 0 : styles.layout
280
- }, beforeElement && (0, _emotion.jsx)("span", {
281
- css: styles === null || styles === void 0 ? void 0 : styles.beforeElement,
282
- ref: e => {
283
- this._beforeElement = e;
284
- }
285
- }, beforeElement), (0, _emotion.jsx)("span", {
286
- css: styles === null || styles === void 0 ? void 0 : styles.innerWrapper
287
- }, (0, _emotion.jsx)("span", {
271
+ }, beforeElement, (0, _emotion.jsx)("span", {
288
272
  css: styles === null || styles === void 0 ? void 0 : styles.inputLayout
289
- }, (0, _emotion.jsx)("span", {
290
- css: styles === null || styles === void 0 ? void 0 : styles.innerWrapper
291
- }, this.renderInput()), afterElement && (0, _emotion.jsx)("span", {
273
+ }, this.renderInput(), afterElement && (0, _emotion.jsx)("span", {
292
274
  css: styles === null || styles === void 0 ? void 0 : styles.afterElement,
293
275
  ref: e => {
294
276
  this._afterElement = e;
295
277
  }
296
- }, afterElement))))) : (/* If no prepended or appended content, don't render Flex layout */
278
+ }, afterElement))) : (/* If no prepended or appended content, don't render Flex layout */
297
279
  this.renderInput())));
298
280
  }
299
281
  }, _TextInput.displayName = "TextInput", _TextInput.componentId = 'TextInput', _TextInput.allowedProps = _props.allowedProps, _TextInput.propTypes = _props.propTypes, _TextInput.defaultProps = {
@@ -45,8 +45,8 @@ const generateStyle = (componentTheme, props, state) => {
45
45
  const disabled = state.disabled,
46
46
  invalid = state.invalid,
47
47
  focused = state.focused,
48
- beforeElementHasWidth = state.beforeElementHasWidth,
49
- afterElementHasWidth = state.afterElementHasWidth;
48
+ afterElementHasWidth = state.afterElementHasWidth,
49
+ beforeElementExists = state.beforeElementExists;
50
50
  const sizeVariants = {
51
51
  small: {
52
52
  fontSize: componentTheme.smallFontSize,
@@ -87,11 +87,11 @@ const generateStyle = (componentTheme, props, state) => {
87
87
  '&::-ms-clear': {
88
88
  display: 'none'
89
89
  },
90
+ width: '100%',
90
91
  WebkitFontSmoothing: 'antialiased',
91
92
  MozOsxFontSmoothing: 'grayscale',
92
93
  appearance: 'none',
93
94
  margin: 0,
94
- width: '100%',
95
95
  display: 'block',
96
96
  boxSizing: 'border-box',
97
97
  outline: 'none',
@@ -128,10 +128,6 @@ const generateStyle = (componentTheme, props, state) => {
128
128
  justifyContent: 'flex-start',
129
129
  flexDirection: 'row'
130
130
  };
131
- const flexItemBase = {
132
- ...viewBase,
133
- flexShrink: 0
134
- };
135
131
  return {
136
132
  requiredInvalid: {
137
133
  color: componentTheme.requiredInvalidColor
@@ -173,32 +169,21 @@ const generateStyle = (componentTheme, props, state) => {
173
169
  },
174
170
  layout: {
175
171
  label: 'textInput__layout',
176
- ...flexBase,
172
+ ...viewBase,
173
+ display: 'flex',
174
+ alignItems: 'center',
175
+ justifyContent: 'flex-start',
176
+ flexDirection: 'row',
177
177
  ...(!shouldNotWrap && {
178
178
  flexWrap: 'wrap'
179
+ }),
180
+ ...(beforeElementExists && {
181
+ paddingInlineStart: componentTheme.padding
179
182
  })
180
183
  },
181
- beforeElement: {
182
- display: 'inline-flex',
183
- alignItems: 'center',
184
- label: 'textInput__beforeElement',
185
- ...flexItemBase,
186
- paddingInlineStart: componentTheme.padding,
187
- // we only override the padding once the width is calculated,
188
- // it needs the padding on render
189
- ...(beforeElementHasWidth === false && {
190
- paddingInlineStart: 0
191
- })
192
- },
193
- innerWrapper: {
194
- label: 'textInput__innerWrapper',
195
- ...flexItemBase,
196
- minWidth: '0.0625rem',
197
- flexShrink: 1,
198
- flexGrow: 1
199
- },
200
184
  inputLayout: {
201
185
  label: 'textInput__inputLayout',
186
+ flexGrow: 1,
202
187
  ...flexBase
203
188
  },
204
189
  afterElement: {
@@ -208,7 +193,8 @@ const generateStyle = (componentTheme, props, state) => {
208
193
  marginTop: '-1px',
209
194
  marginBottom: '-1px',
210
195
  label: 'textInput__afterElement',
211
- ...flexItemBase,
196
+ ...viewBase,
197
+ flexShrink: 0,
212
198
  paddingInlineEnd: componentTheme.padding,
213
199
  // we only override the padding once the width is calculated,
214
200
  // it needs the padding on render
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-text-input",
3
- "version": "10.7.0",
3
+ "version": "10.7.1-snapshot-0",
4
4
  "description": "A styled HTML text input component.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,12 +23,12 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "10.7.0",
27
- "@instructure/ui-babel-preset": "10.7.0",
28
- "@instructure/ui-badge": "10.7.0",
29
- "@instructure/ui-color-utils": "10.7.0",
30
- "@instructure/ui-test-utils": "10.7.0",
31
- "@instructure/ui-themes": "10.7.0",
26
+ "@instructure/ui-axe-check": "10.7.1-snapshot-0",
27
+ "@instructure/ui-babel-preset": "10.7.1-snapshot-0",
28
+ "@instructure/ui-badge": "10.7.1-snapshot-0",
29
+ "@instructure/ui-color-utils": "10.7.1-snapshot-0",
30
+ "@instructure/ui-test-utils": "10.7.1-snapshot-0",
31
+ "@instructure/ui-themes": "10.7.1-snapshot-0",
32
32
  "@testing-library/jest-dom": "^6.4.6",
33
33
  "@testing-library/react": "^16.0.1",
34
34
  "@testing-library/user-event": "^14.5.2",
@@ -36,15 +36,15 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@babel/runtime": "^7.25.6",
39
- "@instructure/emotion": "10.7.0",
40
- "@instructure/shared-types": "10.7.0",
41
- "@instructure/ui-dom-utils": "10.7.0",
42
- "@instructure/ui-form-field": "10.7.0",
43
- "@instructure/ui-icons": "10.7.0",
44
- "@instructure/ui-prop-types": "10.7.0",
45
- "@instructure/ui-react-utils": "10.7.0",
46
- "@instructure/ui-tag": "10.7.0",
47
- "@instructure/ui-testable": "10.7.0",
39
+ "@instructure/emotion": "10.7.1-snapshot-0",
40
+ "@instructure/shared-types": "10.7.1-snapshot-0",
41
+ "@instructure/ui-dom-utils": "10.7.1-snapshot-0",
42
+ "@instructure/ui-form-field": "10.7.1-snapshot-0",
43
+ "@instructure/ui-icons": "10.7.1-snapshot-0",
44
+ "@instructure/ui-prop-types": "10.7.1-snapshot-0",
45
+ "@instructure/ui-react-utils": "10.7.1-snapshot-0",
46
+ "@instructure/ui-tag": "10.7.1-snapshot-0",
47
+ "@instructure/ui-testable": "10.7.1-snapshot-0",
48
48
  "prop-types": "^15.8.1"
49
49
  },
50
50
  "peerDependencies": {
@@ -205,7 +205,7 @@ Focusable content will be focused separately from the input itself.
205
205
  value={this.state.value}
206
206
  onChange={this.handleChange}
207
207
  renderBeforeInput={
208
- <View display="block" padding="xxx-small 0">
208
+ <>
209
209
  {this.state.value !== '' && (
210
210
  <Tag
211
211
  text={this.state.value}
@@ -233,7 +233,7 @@ Focusable content will be focused separately from the input itself.
233
233
  margin="xxx-small xxx-small xxx-small none"
234
234
  onClick={() => console.log('Strawberry')}
235
235
  />
236
- </View>
236
+ </>
237
237
  }
238
238
  renderAfterInput={() => (
239
239
  <Avatar name="Paula Panda" src={avatarSquare} size="x-small" />
@@ -260,7 +260,7 @@ Focusable content will be focused separately from the input itself.
260
260
  value={value}
261
261
  onChange={handleChange}
262
262
  renderBeforeInput={
263
- <View display="block" padding="xxx-small 0">
263
+ <>
264
264
  {value !== '' && (
265
265
  <Tag
266
266
  text={value}
@@ -288,7 +288,7 @@ Focusable content will be focused separately from the input itself.
288
288
  margin="xxx-small xxx-small xxx-small none"
289
289
  onClick={() => console.log('Strawberry')}
290
290
  />
291
- </View>
291
+ </>
292
292
  }
293
293
  renderAfterInput={() => (
294
294
  <Avatar name="Paula Panda" src={avatarSquare} size="x-small" />
@@ -346,7 +346,7 @@ type: example
346
346
  <TextInput
347
347
  renderLabel="I will wrap"
348
348
  renderBeforeInput={
349
- <div>
349
+ <>
350
350
  <Tag
351
351
  text="English 101"
352
352
  margin="xx-small xxx-small"
@@ -355,7 +355,7 @@ type: example
355
355
  text="History 205"
356
356
  margin="xx-small xxx-small"
357
357
  />
358
- </div>
358
+ </>
359
359
  }
360
360
  renderAfterInput={<Avatar name="Paula Panda" src={avatarSquare} size="x-small" />}
361
361
  />
@@ -374,6 +374,7 @@ type: embed
374
374
  <Figure.Item>Left align text (exceptions may apply)</Figure.Item>
375
375
  <Figure.Item>Place labels on top or to the left (inline)</Figure.Item>
376
376
  <Figure.Item>Make placeholder text different than the label</Figure.Item>
377
+ <Figure.Item>Use React fragments for <code>renderBeforeInput</code>. This will nicely float the text input box to the remaining space</Figure.Item>
377
378
  </Figure>
378
379
  <Figure recommendation="no" title="Don't">
379
380
  <Figure.Item>Place labels to the right of the input</Figure.Item>
@@ -77,7 +77,6 @@ class TextInput extends Component<TextInputProps, TextInputState> {
77
77
  super(props)
78
78
  this.state = {
79
79
  hasFocus: false,
80
- beforeElementHasWidth: undefined,
81
80
  afterElementHasWidth: undefined
82
81
  }
83
82
  this._defaultId = props.deterministicId!()
@@ -87,7 +86,6 @@ class TextInput extends Component<TextInputProps, TextInputState> {
87
86
  ref: Element | null = null
88
87
 
89
88
  private _input: HTMLInputElement | null = null
90
- private _beforeElement: HTMLSpanElement | null = null
91
89
  private _afterElement: HTMLSpanElement | null = null
92
90
 
93
91
  private readonly _defaultId: string
@@ -112,13 +110,10 @@ class TextInput extends Component<TextInputProps, TextInputState> {
112
110
  'focus',
113
111
  this.handleFocus
114
112
  )
115
-
116
113
  this.setState({
117
- beforeElementHasWidth: this.getElementHasWidth(this._beforeElement),
118
114
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
119
115
  })
120
116
  }
121
-
122
117
  this.props.makeStyles?.(this.makeStyleProps())
123
118
  }
124
119
 
@@ -129,11 +124,6 @@ class TextInput extends Component<TextInputProps, TextInputState> {
129
124
  }
130
125
 
131
126
  componentDidUpdate(prevProps: TextInputProps) {
132
- if (prevProps.renderBeforeInput !== this.props.renderBeforeInput) {
133
- this.setState({
134
- beforeElementHasWidth: this.getElementHasWidth(this._beforeElement)
135
- })
136
- }
137
127
  if (prevProps.renderAfterInput !== this.props.renderAfterInput) {
138
128
  this.setState({
139
129
  afterElementHasWidth: this.getElementHasWidth(this._afterElement)
@@ -154,13 +144,13 @@ class TextInput extends Component<TextInputProps, TextInputState> {
154
144
 
155
145
  makeStyleProps = (): TextInputStyleProps => {
156
146
  const { interaction } = this
157
- const { hasFocus, beforeElementHasWidth, afterElementHasWidth } = this.state
147
+ const { hasFocus, afterElementHasWidth } = this.state
158
148
  return {
159
149
  disabled: interaction === 'disabled',
160
150
  invalid: this.invalid,
161
151
  focused: hasFocus,
162
- beforeElementHasWidth,
163
- afterElementHasWidth
152
+ afterElementHasWidth: afterElementHasWidth,
153
+ beforeElementExists: this.props.renderBeforeInput != undefined
164
154
  }
165
155
  }
166
156
 
@@ -282,7 +272,7 @@ class TextInput extends Component<TextInputProps, TextInputState> {
282
272
  )
283
273
  }
284
274
 
285
- getElementHasWidth(element: HTMLSpanElement | null) {
275
+ getElementHasWidth(element: Element | null) {
286
276
  if (!element) {
287
277
  return undefined
288
278
  }
@@ -360,39 +350,24 @@ class TextInput extends Component<TextInputProps, TextInputState> {
360
350
  >
361
351
  <span css={styles?.facade}>
362
352
  {renderBeforeOrAfter ? (
363
- <div>
364
- <span css={styles?.layout}>
365
- {beforeElement && (
353
+ <span css={styles?.layout}>
354
+ {beforeElement}
355
+ {/* The input and content after input should not wrap,
356
+ so they're in their own flex container */}
357
+ <span css={styles?.inputLayout}>
358
+ {this.renderInput()}
359
+ {afterElement && (
366
360
  <span
367
- css={styles?.beforeElement}
361
+ css={styles?.afterElement}
368
362
  ref={(e) => {
369
- this._beforeElement = e
363
+ this._afterElement = e
370
364
  }}
371
365
  >
372
- {beforeElement}
366
+ {afterElement}
373
367
  </span>
374
368
  )}
375
- <span css={styles?.innerWrapper}>
376
- {/*
377
- The input and content after input should not wrap,
378
- so they're in their own flex container
379
- */}
380
- <span css={styles?.inputLayout}>
381
- <span css={styles?.innerWrapper}>{this.renderInput()}</span>
382
- {afterElement && (
383
- <span
384
- css={styles?.afterElement}
385
- ref={(e) => {
386
- this._afterElement = e
387
- }}
388
- >
389
- {afterElement}
390
- </span>
391
- )}
392
- </span>
393
- </span>
394
369
  </span>
395
- </div>
370
+ </span>
396
371
  ) : (
397
372
  /* If no prepended or appended content, don't render Flex layout */
398
373
  this.renderInput()
@@ -193,11 +193,9 @@ type TextInputStyle = ComponentStyle<
193
193
  | 'textInput'
194
194
  | 'facade'
195
195
  | 'layout'
196
- | 'beforeElement'
197
- | 'innerWrapper'
198
- | 'inputLayout'
199
196
  | 'afterElement'
200
197
  | 'requiredInvalid'
198
+ | 'inputLayout'
201
199
  >
202
200
 
203
201
  const propTypes: PropValidators<PropKeys> = {
@@ -254,7 +252,6 @@ const allowedProps: AllowedPropKeys = [
254
252
 
255
253
  type TextInputState = {
256
254
  hasFocus: boolean
257
- beforeElementHasWidth?: boolean
258
255
  afterElementHasWidth?: boolean
259
256
  }
260
257
 
@@ -262,8 +259,8 @@ type TextInputStyleProps = {
262
259
  disabled: boolean
263
260
  invalid: boolean
264
261
  focused: TextInputState['hasFocus']
265
- beforeElementHasWidth: TextInputState['beforeElementHasWidth']
266
262
  afterElementHasWidth: TextInputState['afterElementHasWidth']
263
+ beforeElementExists: boolean
267
264
  }
268
265
 
269
266
  export type {