mirror of
https://github.com/discourse/discourse.git
synced 2025-02-23 02:26:40 +08:00
FIX: ensures sk can be scrolled on iOS in a modal (#30164)
The modal was disabling body scroll lock and select-kit collection was not whitelisted which was preventing users to be able to scroll a select-kit collection on iOS.
This commit is contained in:
parent
5759d80091
commit
97e593bfbf
@ -1,5 +1,10 @@
|
|||||||
{{#if this.collection.content.length}}
|
{{#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"
|
||||||
|
{{this.bodyScrollLock}}
|
||||||
|
>
|
||||||
{{#each this.collection.content as |item index|}}
|
{{#each this.collection.content as |item index|}}
|
||||||
{{component
|
{{component
|
||||||
(component-for-row this.collection.identifier item this.selectKit)
|
(component-for-row this.collection.identifier item this.selectKit)
|
||||||
|
@ -1,5 +1,35 @@
|
|||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { service } from "@ember/service";
|
||||||
import { tagName } from "@ember-decorators/component";
|
import { tagName } from "@ember-decorators/component";
|
||||||
|
import { modifier } from "ember-modifier";
|
||||||
|
import {
|
||||||
|
disableBodyScroll,
|
||||||
|
enableBodyScroll,
|
||||||
|
} from "discourse/lib/body-scroll-lock";
|
||||||
|
|
||||||
@tagName("")
|
@tagName("")
|
||||||
export default class SelectKitCollection extends Component {}
|
export default class SelectKitCollection extends Component {
|
||||||
|
@service site;
|
||||||
|
|
||||||
|
bodyScrollLock = modifier((element) => {
|
||||||
|
if (!this.site.mobileView) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// when opened a modal will disable all scroll but itself
|
||||||
|
// this code is whitelisting the collection to ensure it can be scrolled in this case
|
||||||
|
// however we only want to do this if the modal is open to avoid breaking the scroll on the page
|
||||||
|
// eg: opening a combobox under a topic shouldn't prevent you to scroll the topic page
|
||||||
|
const isModalOpen =
|
||||||
|
document.documentElement.classList.contains("modal-open");
|
||||||
|
if (!isModalOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
disableBodyScroll(element);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
enableBodyScroll(element);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user