terrier-engine 4.22.1 → 4.22.2

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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  "*"
6
6
  ],
7
- "version": "4.22.1",
7
+ "version": "4.22.2",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -57,17 +57,23 @@ export class SelectFieldPart<T extends SelectFieldState> extends TerrierPart<T>
57
57
  }
58
58
 
59
59
  populateOptionIfBlank(option: SelectOption) {
60
- let newValue = option.value
61
- let newTitle = option.title
62
-
63
- if (option.value == '' && option.title === undefined) {
64
- newValue = null
65
- newTitle = ''
66
- } else if (option.value == null && option.title === undefined) {
67
- newValue = ''
68
- newTitle = ''
60
+ if (option.title === undefined) {
61
+ // consider option groups and flatten the options
62
+ const options = this.state.options.flatMap((option) => {
63
+ if ('group' in option) {
64
+ return option.options
65
+ } else return option
66
+ })
67
+
68
+ // find the option where title is empty and use that as the blank option value
69
+ return options.find((opt) => {
70
+ if ('title' in opt) {
71
+ return opt.title == ''
72
+ } else return false
73
+ }) || option
74
+ } else {
75
+ return option
69
76
  }
70
- return { title: newTitle, value: newValue }
71
77
  }
72
78
 
73
79
  render(parent: PartTag) {