@instructure/ui-text-input 10.15.3-snapshot-2 → 10.16.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,9 +3,12 @@
|
|
|
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
|
-
|
|
6
|
+
# [10.16.0](https://github.com/instructure/instructure-ui/compare/v10.15.2...v10.16.0) (2025-04-11)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-text-input:** make TextInput maintain focus when renderAfterInput is conditionally rendered ([c124e16](https://github.com/instructure/instructure-ui/commit/c124e16000e1d60e49372ade27633dbeb48e22ae))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/TextInput/index.js
CHANGED
|
@@ -64,12 +64,13 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
64
64
|
const _this$state = this.state,
|
|
65
65
|
hasFocus = _this$state.hasFocus,
|
|
66
66
|
afterElementHasWidth = _this$state.afterElementHasWidth;
|
|
67
|
+
const beforeElement = this.props.renderBeforeInput ? callRenderProp(this.props.renderBeforeInput) : null;
|
|
67
68
|
return {
|
|
68
69
|
disabled: interaction === 'disabled',
|
|
69
70
|
invalid: this.invalid,
|
|
70
71
|
focused: hasFocus,
|
|
71
72
|
afterElementHasWidth: afterElementHasWidth,
|
|
72
|
-
beforeElementExists:
|
|
73
|
+
beforeElementExists: !!beforeElement
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
76
|
this.handleInputRef = node => {
|
|
@@ -235,7 +236,7 @@ let TextInput = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
235
236
|
styles = _this$props4.styles;
|
|
236
237
|
const beforeElement = renderBeforeInput ? callRenderProp(renderBeforeInput) : null;
|
|
237
238
|
const afterElement = renderAfterInput ? callRenderProp(renderAfterInput) : null;
|
|
238
|
-
const renderBeforeOrAfter = !!beforeElement || !!afterElement;
|
|
239
|
+
const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !== void 0 || renderAfterInput !== void 0;
|
|
239
240
|
const rawLabel = callRenderProp(renderLabel);
|
|
240
241
|
const label = hasVisibleChildren(rawLabel) ? jsx(React.Fragment, null, rawLabel, isRequired && jsx("span", {
|
|
241
242
|
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
package/lib/TextInput/index.js
CHANGED
|
@@ -74,12 +74,13 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
74
74
|
const _this$state = this.state,
|
|
75
75
|
hasFocus = _this$state.hasFocus,
|
|
76
76
|
afterElementHasWidth = _this$state.afterElementHasWidth;
|
|
77
|
+
const beforeElement = this.props.renderBeforeInput ? (0, _callRenderProp.callRenderProp)(this.props.renderBeforeInput) : null;
|
|
77
78
|
return {
|
|
78
79
|
disabled: interaction === 'disabled',
|
|
79
80
|
invalid: this.invalid,
|
|
80
81
|
focused: hasFocus,
|
|
81
82
|
afterElementHasWidth: afterElementHasWidth,
|
|
82
|
-
beforeElementExists:
|
|
83
|
+
beforeElementExists: !!beforeElement
|
|
83
84
|
};
|
|
84
85
|
};
|
|
85
86
|
this.handleInputRef = node => {
|
|
@@ -245,7 +246,7 @@ let TextInput = exports.TextInput = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
245
246
|
styles = _this$props4.styles;
|
|
246
247
|
const beforeElement = renderBeforeInput ? (0, _callRenderProp.callRenderProp)(renderBeforeInput) : null;
|
|
247
248
|
const afterElement = renderAfterInput ? (0, _callRenderProp.callRenderProp)(renderAfterInput) : null;
|
|
248
|
-
const renderBeforeOrAfter = !!beforeElement || !!afterElement;
|
|
249
|
+
const renderBeforeOrAfter = !!beforeElement || !!afterElement || renderBeforeInput !== void 0 || renderAfterInput !== void 0;
|
|
249
250
|
const rawLabel = (0, _callRenderProp.callRenderProp)(renderLabel);
|
|
250
251
|
const label = (0, _hasVisibleChildren.hasVisibleChildren)(rawLabel) ? (0, _emotion.jsx)(_react.default.Fragment, null, rawLabel, isRequired && (0, _emotion.jsx)("span", {
|
|
251
252
|
css: this.invalid ? styles === null || styles === void 0 ? void 0 : styles.requiredInvalid : {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-text-input",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.16.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.
|
|
27
|
-
"@instructure/ui-babel-preset": "10.
|
|
28
|
-
"@instructure/ui-badge": "10.
|
|
29
|
-
"@instructure/ui-color-utils": "10.
|
|
30
|
-
"@instructure/ui-test-utils": "10.
|
|
31
|
-
"@instructure/ui-themes": "10.
|
|
26
|
+
"@instructure/ui-axe-check": "10.16.0",
|
|
27
|
+
"@instructure/ui-babel-preset": "10.16.0",
|
|
28
|
+
"@instructure/ui-badge": "10.16.0",
|
|
29
|
+
"@instructure/ui-color-utils": "10.16.0",
|
|
30
|
+
"@instructure/ui-test-utils": "10.16.0",
|
|
31
|
+
"@instructure/ui-themes": "10.16.0",
|
|
32
32
|
"@testing-library/jest-dom": "^6.6.3",
|
|
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.26.0",
|
|
39
|
-
"@instructure/emotion": "10.
|
|
40
|
-
"@instructure/shared-types": "10.
|
|
41
|
-
"@instructure/ui-dom-utils": "10.
|
|
42
|
-
"@instructure/ui-form-field": "10.
|
|
43
|
-
"@instructure/ui-icons": "10.
|
|
44
|
-
"@instructure/ui-prop-types": "10.
|
|
45
|
-
"@instructure/ui-react-utils": "10.
|
|
46
|
-
"@instructure/ui-tag": "10.
|
|
47
|
-
"@instructure/ui-testable": "10.
|
|
39
|
+
"@instructure/emotion": "10.16.0",
|
|
40
|
+
"@instructure/shared-types": "10.16.0",
|
|
41
|
+
"@instructure/ui-dom-utils": "10.16.0",
|
|
42
|
+
"@instructure/ui-form-field": "10.16.0",
|
|
43
|
+
"@instructure/ui-icons": "10.16.0",
|
|
44
|
+
"@instructure/ui-prop-types": "10.16.0",
|
|
45
|
+
"@instructure/ui-react-utils": "10.16.0",
|
|
46
|
+
"@instructure/ui-tag": "10.16.0",
|
|
47
|
+
"@instructure/ui-testable": "10.16.0",
|
|
48
48
|
"prop-types": "^15.8.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
package/src/TextInput/index.tsx
CHANGED
|
@@ -145,12 +145,15 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
145
145
|
makeStyleProps = (): TextInputStyleProps => {
|
|
146
146
|
const { interaction } = this
|
|
147
147
|
const { hasFocus, afterElementHasWidth } = this.state
|
|
148
|
+
const beforeElement = this.props.renderBeforeInput
|
|
149
|
+
? callRenderProp(this.props.renderBeforeInput)
|
|
150
|
+
: null
|
|
148
151
|
return {
|
|
149
152
|
disabled: interaction === 'disabled',
|
|
150
153
|
invalid: this.invalid,
|
|
151
154
|
focused: hasFocus,
|
|
152
155
|
afterElementHasWidth: afterElementHasWidth,
|
|
153
|
-
beforeElementExists:
|
|
156
|
+
beforeElementExists: !!beforeElement
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
|
|
@@ -309,7 +312,11 @@ class TextInput extends Component<TextInputProps, TextInputState> {
|
|
|
309
312
|
? callRenderProp(renderAfterInput)
|
|
310
313
|
: null
|
|
311
314
|
|
|
312
|
-
const renderBeforeOrAfter =
|
|
315
|
+
const renderBeforeOrAfter =
|
|
316
|
+
!!beforeElement ||
|
|
317
|
+
!!afterElement ||
|
|
318
|
+
renderBeforeInput !== undefined ||
|
|
319
|
+
renderAfterInput !== undefined
|
|
313
320
|
|
|
314
321
|
const rawLabel = callRenderProp(renderLabel)
|
|
315
322
|
const label = hasVisibleChildren(rawLabel) ? (
|