DEV: applies body-scroll-lock on select-kit (#26397)

This will prevent any scrolling issues with sk when on mobile, especially on iOS and in modals.

Prior to this fix, scrolling could sometimes stop working in dropdowns.
This commit is contained in:
Joffrey JAFFEUX 2024-03-27 13:33:21 +01:00 committed by GitHub
parent e911362864
commit 2146ab492b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 1 deletions

View File

@ -1,5 +1,11 @@
{{#if this.collection.content.length}}
<ul class="select-kit-collection" aria-live="polite" role="menu">
<ul
class="select-kit-collection"
aria-live="polite"
role="menu"
{{did-insert this.lock}}
{{will-destroy this.unlock}}
>
{{#each this.collection.content as |item index|}}
{{component
(component-for-row this.collection.identifier item this.selectKit)

View File

@ -1,5 +1,20 @@
import Component from "@ember/component";
import { action } from "@ember/object";
import {
disableBodyScroll,
enableBodyScroll,
} from "discourse/lib/body-scroll-lock";
export default Component.extend({
tagName: "",
@action
lock(element) {
disableBodyScroll(element);
},
@action
unlock(element) {
enableBodyScroll(element);
},
});