goblin-magic 1.0.13 → 1.0.14

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,6 +1,6 @@
1
1
  {
2
2
  "name": "goblin-magic",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "goblin-magic",
5
5
  "author": "Epsitec SA",
6
6
  "contributors": [
@@ -299,7 +299,19 @@ class MenuContent extends Widget {
299
299
  const firstTop = firstPos === 'top';
300
300
 
301
301
  if (size.height > window.innerHeight) {
302
- return 'full';
302
+ if (state.fromContextMenu) {
303
+ return 'full';
304
+ }
305
+
306
+ // Prevent overlap on the button
307
+ const spaceAbove = top;
308
+ const spaceBelow = window.innerHeight - bottom;
309
+
310
+ if (firstBottom || (!firstTop && spaceBelow >= spaceAbove)) {
311
+ return 'bottom-constrained'; // Open to the bottom
312
+ } else {
313
+ return 'top-constrained'; // Open to the top
314
+ }
303
315
  }
304
316
 
305
317
  if (firstBottom || firstTop) {
@@ -349,6 +361,8 @@ class MenuContent extends Widget {
349
361
  'start': {top: 0},
350
362
  'end': {bottom: 0},
351
363
  'full': {top: 0, bottom: 0},
364
+ 'bottom-constrained': {top: bottom, bottom: '8px'},
365
+ 'top-constrained': {top: '8px', bottom: `calc(100% - ${top}px)`},
352
366
  }[verticalPos];
353
367
 
354
368
  const horizontalPos = (() => {