DEV: applyBehaviorTransformer for composer-position editTouchMove (#30811)

In a theme or plugin, if you have a scrollable mobile composer, you may
want to allow scrolling events on the composer editor.. this allows for
it!
This commit is contained in:
Mark VanLandingham 2025-01-16 08:04:15 -06:00 committed by GitHub
parent 72f4588d3b
commit e6272e0497
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import { later } from "@ember/runloop";
import { applyBehaviorTransformer } from "discourse/lib/transformer";
export function setupComposerPosition(editor) {
// This component contains two composer positioning adjustments
@ -10,11 +11,13 @@ export function setupComposerPosition(editor) {
// This is an alternative to locking up the body
// It stops scrolling in the given element from bubbling up to the body
// when the editor does not have any content to scroll
applyBehaviorTransformer("composer-position:editor-touch-move", () => {
const notScrollable = editor.scrollHeight <= editor.clientHeight;
if (notScrollable) {
event.preventDefault();
event.stopPropagation();
}
});
}
if (

View File

@ -1,5 +1,6 @@
export const BEHAVIOR_TRANSFORMERS = Object.freeze([
// use only lowercase names
"composer-position:editor-touch-move",
"discovery-topic-list-load-more",
"full-page-search-load-more",
]);