FIX: tweaks of select-kit on mobile (#26401)

- uses footer-nav height and safe-area-inset-bottom as bottom padding
- body scroll lock select-kit only when inside a modal
This commit is contained in:
Joffrey JAFFEUX 2024-03-27 17:26:24 +01:00 committed by GitHub
parent 65c03af919
commit 88b9f0bc56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 33 additions and 0 deletions

View File

@ -916,6 +916,26 @@ export default Component.extend(
);
const strategy = this._computePlacementStrategy();
let bottomOffset = 0;
if (this.capabilities.isIOS) {
bottomOffset +=
parseInt(
getComputedStyle(document.documentElement)
.getPropertyValue("--safe-area-inset-bottom")
.trim(),
10
) || 0;
}
if (this.site.mobileView) {
bottomOffset +=
parseInt(
getComputedStyle(document.documentElement)
.getPropertyValue("--footer-nav-height")
.trim(),
10
) || 0;
}
this.popper = createPopper(anchor, popper, {
eventsEnabled: false,
strategy,
@ -940,6 +960,7 @@ export default Component.extend(
),
10
) || 0,
bottom: bottomOffset,
},
},
},

View File

@ -1,3 +1,4 @@
import { cached } from "@glimmer/tracking";
import Component from "@ember/component";
import { action } from "@ember/object";
import {
@ -8,8 +9,18 @@ import {
export default Component.extend({
tagName: "",
@cached
get inModal() {
const element = this.selectKit.mainElement();
return element.closest(".d-modal");
},
@action
lock(element) {
if (!this.inModal) {
return;
}
disableBodyScroll(element);
},

View File

@ -10,6 +10,7 @@
--d-input-bg-color--disabled: var(--primary-low);
--d-input-text-color--disabled: var(--primary);
--d-input-border--disabled: 1px solid var(--primary-low);
--safe-area-inset-bottom: env(safe-area-inset-bottom);
}
// Animation Keyframes