@budibase/bbui 3.23.5 → 3.23.6

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/bbui",
3
3
  "description": "A UI solution used in the different Budibase projects.",
4
- "version": "3.23.5",
4
+ "version": "3.23.6",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.ts",
7
7
  "module": "dist/bbui.mjs",
@@ -106,5 +106,5 @@
106
106
  }
107
107
  }
108
108
  },
109
- "gitHead": "481d9c7c88d91cc07c8682307360a9b231f1dfe4"
109
+ "gitHead": "993c44f2265cdca05008c355c1225967e2eb10c2"
110
110
  }
@@ -94,10 +94,14 @@ export default function positionDropdown(element: HTMLElement, opts: Opts) {
94
94
  const overflows = styles.left + elementBounds.width > winWidth
95
95
  return overflows && anchorBounds.left > winWidth - anchorBounds.right
96
96
  }
97
- const doesYOverflow = () => {
97
+ const doesYOverflowBottom = () => {
98
98
  const overflows = styles.top + elementBounds.height > winHeight
99
99
  return overflows && anchorBounds.top > winHeight - anchorBounds.bottom
100
100
  }
101
+ const doesYOverflowTop = () => {
102
+ const overflows = styles.top < screenOffset
103
+ return overflows && anchorBounds.bottom < winHeight - anchorBounds.top
104
+ }
101
105
 
102
106
  // Applies a dynamic max height constraint if appropriate
103
107
  const applyMaxHeight = (height: number) => {
@@ -167,6 +171,12 @@ export default function positionDropdown(element: HTMLElement, opts: Opts) {
167
171
  }
168
172
  }
169
173
 
174
+ // Applies top edge sticking when popover overflows above viewport
175
+ const applyTopEdgeStick = () => {
176
+ styles.top = screenOffset
177
+ applyMaxHeight(winHeight - 2 * screenOffset)
178
+ }
179
+
170
180
  // Determine X strategy
171
181
  if (align === PopoverAlignment.Right) {
172
182
  applyXStrategy("EndToEnd")
@@ -215,12 +225,12 @@ export default function positionDropdown(element: HTMLElement, opts: Opts) {
215
225
  applyXStrategy("EndToStart")
216
226
  }
217
227
  }
218
- if (doesYOverflow()) {
228
+ if (doesYOverflowBottom()) {
219
229
  // If wrapping, lock to the bottom of the screen and also reposition to
220
230
  // the side to not block the anchor
221
231
  if (wrap) {
222
232
  applyYStrategy("MidPoint")
223
- if (doesYOverflow()) {
233
+ if (doesYOverflowBottom()) {
224
234
  applyYStrategy("ScreenEdge")
225
235
  }
226
236
  applyXStrategy("StartToEnd")
@@ -243,6 +253,15 @@ export default function positionDropdown(element: HTMLElement, opts: Opts) {
243
253
  }
244
254
  }
245
255
  }
256
+ // Handle top overflow for outside alignments
257
+ if (doesYOverflowTop()) {
258
+ if (
259
+ align === PopoverAlignment.LeftOutside ||
260
+ align === PopoverAlignment.RightOutside
261
+ ) {
262
+ applyTopEdgeStick()
263
+ }
264
+ }
246
265
  }
247
266
 
248
267
  for (const [key, value] of Object.entries(styles)) {