terrier-engine 4.22.0 → 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.0",
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) {
@@ -171,7 +177,7 @@ export class SelectOptionsDropdown extends Dropdown<SelectFieldDropdownState> {
171
177
  let scrollAmount = selectedElement.offsetTop - anchorRect.top
172
178
  let scrollTop = anchorRect.y + (anchorRect.height / 2) - (selectOptionSize.height / 2)
173
179
 
174
- if (dropdown.offsetHeight > win.height - anchorRect.top) { // attempting to fill the whole window height with the dropdownContainer, so we need to adjust scroll of dropdownContainer
180
+ if (dropdown.offsetHeight > win.height - anchorRect.top || anchorRect.top - dropdown.offsetHeight < 0) { // attempting to fill the whole window height with the dropdownContainer, so we need to adjust scroll of dropdownContainer
175
181
  if (scrollAmount < 0) { // space above the dropdown
176
182
  dropdown.style.marginTop = `${-scrollAmount}px`
177
183
  scrollTop = 0