Skip to content

A platform for community discussion. Free, open, simple.

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

Joffrey JAFFEUX2146ab492b87
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.hbs b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.hbs
index d52ec3e195d..c9e18bfd767 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.hbs
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.hbs
@@ -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)
diff --git a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.js b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.js
index 44494409ab5..71dbcfe8d17 100644
--- a/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.js
+++ b/app/assets/javascripts/select-kit/addon/components/select-kit/select-kit-collection.js
@@ -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);
+ },
});