@instructure/ui-simple-select 10.9.1-snapshot-0 → 10.9.1-snapshot-1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -2
- package/es/SimpleSelect/index.js +5 -1
- package/lib/SimpleSelect/index.js +5 -1
- package/package.json +15 -15
- package/src/SimpleSelect/index.tsx +6 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/SimpleSelect/index.d.ts +1 -1
- package/types/SimpleSelect/index.d.ts.map +1 -1
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
|
-
## [10.9.1-snapshot-
|
6
|
+
## [10.9.1-snapshot-1](https://github.com/instructure/instructure-ui/compare/v10.9.0...v10.9.1-snapshot-1) (2024-12-13)
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **ui-simple-select:** fix selection getting lost after options have changed ([4e07f9a](https://github.com/instructure/instructure-ui/commit/4e07f9a5b8c7823dfcbf40273e28a448cfae59fb))
|
9
12
|
|
10
13
|
|
11
14
|
|
package/es/SimpleSelect/index.js
CHANGED
@@ -189,13 +189,17 @@ let SimpleSelect = (_dec = withDeterministicId(), _dec2 = testable(), _dec(_clas
|
|
189
189
|
}
|
190
190
|
componentDidUpdate(prevProps) {
|
191
191
|
if (this.hasOptionsChanged(prevProps.children, this.props.children)) {
|
192
|
-
|
192
|
+
// Compare current input value to children's child prop, this is put into
|
193
|
+
// state.inputValue
|
194
|
+
const option = this.getOption('children', this.state.inputValue);
|
193
195
|
this.setState({
|
194
196
|
inputValue: option ? option.props.children : void 0,
|
195
197
|
selectedOptionId: option ? option.props.id : ''
|
196
198
|
});
|
197
199
|
}
|
198
200
|
if (this.props.value !== prevProps.value) {
|
201
|
+
// if value has changed externally try to find an option with the same value
|
202
|
+
// and select it
|
199
203
|
let option = this.getOption('value', this.props.value);
|
200
204
|
if (typeof this.props.value === 'undefined') {
|
201
205
|
// preserve current value when changing from controlled to uncontrolled
|
@@ -200,13 +200,17 @@ let SimpleSelect = exports.SimpleSelect = (_dec = (0, _withDeterministicId.withD
|
|
200
200
|
}
|
201
201
|
componentDidUpdate(prevProps) {
|
202
202
|
if (this.hasOptionsChanged(prevProps.children, this.props.children)) {
|
203
|
-
|
203
|
+
// Compare current input value to children's child prop, this is put into
|
204
|
+
// state.inputValue
|
205
|
+
const option = this.getOption('children', this.state.inputValue);
|
204
206
|
this.setState({
|
205
207
|
inputValue: option ? option.props.children : void 0,
|
206
208
|
selectedOptionId: option ? option.props.id : ''
|
207
209
|
});
|
208
210
|
}
|
209
211
|
if (this.props.value !== prevProps.value) {
|
212
|
+
// if value has changed externally try to find an option with the same value
|
213
|
+
// and select it
|
210
214
|
let option = this.getOption('value', this.props.value);
|
211
215
|
if (typeof this.props.value === 'undefined') {
|
212
216
|
// preserve current value when changing from controlled to uncontrolled
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-simple-select",
|
3
|
-
"version": "10.9.1-snapshot-
|
3
|
+
"version": "10.9.1-snapshot-1",
|
4
4
|
"description": "A component for standard select element behavior.",
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
6
6
|
"module": "./es/index.js",
|
@@ -24,23 +24,23 @@
|
|
24
24
|
"license": "MIT",
|
25
25
|
"dependencies": {
|
26
26
|
"@babel/runtime": "^7.26.0",
|
27
|
-
"@instructure/console": "10.9.1-snapshot-
|
28
|
-
"@instructure/shared-types": "10.9.1-snapshot-
|
29
|
-
"@instructure/ui-form-field": "10.9.1-snapshot-
|
30
|
-
"@instructure/ui-position": "10.9.1-snapshot-
|
31
|
-
"@instructure/ui-prop-types": "10.9.1-snapshot-
|
32
|
-
"@instructure/ui-react-utils": "10.9.1-snapshot-
|
33
|
-
"@instructure/ui-select": "10.9.1-snapshot-
|
34
|
-
"@instructure/ui-testable": "10.9.1-snapshot-
|
27
|
+
"@instructure/console": "10.9.1-snapshot-1",
|
28
|
+
"@instructure/shared-types": "10.9.1-snapshot-1",
|
29
|
+
"@instructure/ui-form-field": "10.9.1-snapshot-1",
|
30
|
+
"@instructure/ui-position": "10.9.1-snapshot-1",
|
31
|
+
"@instructure/ui-prop-types": "10.9.1-snapshot-1",
|
32
|
+
"@instructure/ui-react-utils": "10.9.1-snapshot-1",
|
33
|
+
"@instructure/ui-select": "10.9.1-snapshot-1",
|
34
|
+
"@instructure/ui-testable": "10.9.1-snapshot-1",
|
35
35
|
"prop-types": "^15.8.1"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
|
-
"@instructure/ui-axe-check": "10.9.1-snapshot-
|
39
|
-
"@instructure/ui-babel-preset": "10.9.1-snapshot-
|
40
|
-
"@instructure/ui-color-utils": "10.9.1-snapshot-
|
41
|
-
"@instructure/ui-icons": "10.9.1-snapshot-
|
42
|
-
"@instructure/ui-test-utils": "10.9.1-snapshot-
|
43
|
-
"@instructure/ui-utils": "10.9.1-snapshot-
|
38
|
+
"@instructure/ui-axe-check": "10.9.1-snapshot-1",
|
39
|
+
"@instructure/ui-babel-preset": "10.9.1-snapshot-1",
|
40
|
+
"@instructure/ui-color-utils": "10.9.1-snapshot-1",
|
41
|
+
"@instructure/ui-icons": "10.9.1-snapshot-1",
|
42
|
+
"@instructure/ui-test-utils": "10.9.1-snapshot-1",
|
43
|
+
"@instructure/ui-utils": "10.9.1-snapshot-1",
|
44
44
|
"@testing-library/jest-dom": "^6.6.3",
|
45
45
|
"@testing-library/react": "^16.0.1",
|
46
46
|
"@testing-library/user-event": "^14.5.2",
|
@@ -51,7 +51,7 @@ import { allowedProps, propTypes, SimpleSelectState } from './props'
|
|
51
51
|
type OptionChild = React.ComponentElement<SimpleSelectOptionProps, Option>
|
52
52
|
type GroupChild = React.ComponentElement<SimpleSelectGroupProps, Group>
|
53
53
|
|
54
|
-
type GetOption = <F extends
|
54
|
+
type GetOption = <F extends keyof SimpleSelectOptionProps>(
|
55
55
|
field: F,
|
56
56
|
value?: SimpleSelectOptionProps[F]
|
57
57
|
) => OptionChild | undefined
|
@@ -150,14 +150,17 @@ class SimpleSelect extends Component<SimpleSelectProps, SimpleSelectState> {
|
|
150
150
|
|
151
151
|
componentDidUpdate(prevProps: SimpleSelectProps) {
|
152
152
|
if (this.hasOptionsChanged(prevProps.children, this.props.children)) {
|
153
|
-
|
153
|
+
// Compare current input value to children's child prop, this is put into
|
154
|
+
// state.inputValue
|
155
|
+
const option = this.getOption('children', this.state.inputValue)
|
154
156
|
this.setState({
|
155
157
|
inputValue: option ? option.props.children : undefined,
|
156
158
|
selectedOptionId: option ? option.props.id : ''
|
157
159
|
})
|
158
160
|
}
|
159
|
-
|
160
161
|
if (this.props.value !== prevProps.value) {
|
162
|
+
// if value has changed externally try to find an option with the same value
|
163
|
+
// and select it
|
161
164
|
let option = this.getOption('value', this.props.value)
|
162
165
|
if (typeof this.props.value === 'undefined') {
|
163
166
|
// preserve current value when changing from controlled to uncontrolled
|