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
|
@@ -57,17 +57,23 @@ export class SelectFieldPart<T extends SelectFieldState> extends TerrierPart<T>
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
populateOptionIfBlank(option: SelectOption) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|