terrier-engine 4.22.1 → 4.22.3

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.3",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Terrier-Tech/terrier-engine"
@@ -26,7 +26,9 @@ export class SelectFieldPart<T extends SelectFieldState> extends TerrierPart<T>
26
26
  async init() {
27
27
  await super.init()
28
28
  this.state.selected_option = this.populateOptionIfBlank(this.state.selected_option)
29
- this.onClick(this._toggleDropdownKey, () => {
29
+ this.onClick(this._toggleDropdownKey, m => {
30
+ const target = m.event.currentTarget as HTMLElement
31
+ if (target.classList.contains('disabled')) return
30
32
  this.toggleDropdown(SelectOptionsDropdown, {
31
33
  options: this.state.options,
32
34
  selected_option: this.state.selected_option,
@@ -57,17 +59,23 @@ export class SelectFieldPart<T extends SelectFieldState> extends TerrierPart<T>
57
59
  }
58
60
 
59
61
  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 = ''
62
+ if (option.title === undefined) {
63
+ // consider option groups and flatten the options
64
+ const options = this.state.options.flatMap((option) => {
65
+ if ('group' in option) {
66
+ return option.options
67
+ } else return option
68
+ })
69
+
70
+ // find the option where title is empty and use that as the blank option value
71
+ return options.find((opt) => {
72
+ if ('title' in opt) {
73
+ return opt.title == ''
74
+ } else return false
75
+ }) || option
76
+ } else {
77
+ return option
69
78
  }
70
- return { title: newTitle, value: newValue }
71
79
  }
72
80
 
73
81
  render(parent: PartTag) {