From ec620f98a6e494713ebea7aeff9b2e567839b69b Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Thu, 30 Oct 2025 13:57:20 -0500 Subject: [PATCH] Need to opt-out of orient-top if there isn't space above --- app/assets/stylesheets/popup.css | 4 ++++ app/javascript/helpers/orientation_helpers.js | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/popup.css b/app/assets/stylesheets/popup.css index b258086d0..fbfd8f7c2 100644 --- a/app/assets/stylesheets/popup.css +++ b/app/assets/stylesheets/popup.css @@ -32,6 +32,10 @@ &.orient-top { inset-block: auto 0; + + &.orient-bottom { + inset-block: 0 auto; + } } &:has(.popup__footer) { diff --git a/app/javascript/helpers/orientation_helpers.js b/app/javascript/helpers/orientation_helpers.js index 4e3f1a3a5..672275778 100644 --- a/app/javascript/helpers/orientation_helpers.js +++ b/app/javascript/helpers/orientation_helpers.js @@ -4,7 +4,8 @@ export function orient(el, orient = true) { const directions = [ ["orient-left", spaceOnRight], ["orient-right", spaceOnLeft], - ["orient-top", spaceOnBottom] + ["orient-top", spaceOnBottom], + ["orient-bottom", spaceOnTop] ]; directions.forEach(([className, fn]) => @@ -23,3 +24,7 @@ function spaceOnRight(el) { function spaceOnBottom(el) { return window.innerHeight - el.getBoundingClientRect().bottom } + +function spaceOnTop(el) { + return el.getBoundingClientRect().top +}