FIX: simplify body scroll lock on iOS (#30696)

This will have the following advantages:
- removes a very annoying bug which was making text selection super hard on iOS
- removes the flashing of header when transitioning from disable to enable body scroll lock
This commit is contained in:
Joffrey JAFFEUX
2025-01-10 17:13:48 +01:00
committed by GitHub
parent 07e5f8907e
commit b96a9b9896
4 changed files with 16 additions and 78 deletions

View File

@ -12,10 +12,6 @@ import { Promise } from "rsvp";
import EmojiPickerDetached from "discourse/components/emoji-picker/detached";
import InsertHyperlink from "discourse/components/modal/insert-hyperlink";
import { SKIP } from "discourse/lib/autocomplete";
import {
disableBodyScroll,
enableBodyScroll,
} from "discourse/lib/body-scroll-lock";
import { setupHashtagAutocomplete } from "discourse/lib/hashtag-autocomplete";
import { emojiUrlFor } from "discourse/lib/text";
import userSearch from "discourse/lib/user-search";
@ -285,22 +281,20 @@ export default class ChatComposer extends Component {
}
@action
onTextareaFocusOut(event) {
onTextareaFocusOut() {
this.isFocused = false;
enableBodyScroll(event.target);
}
@action
onTextareaFocusIn(event) {
this.isFocused = true;
const textarea = event.target;
disableBodyScroll(textarea);
if (!this.capabilities.isIOS) {
return;
}
// hack to prevent the whole viewport to move on focus input
const textarea = event.target;
textarea.style.transform = "translateY(-99999px)";
textarea.focus();
window.requestAnimationFrame(() => {

View File

@ -22,5 +22,7 @@
color: var(--primary-medium);
font-size: var(--font-down-1);
padding: 0.5em 0.25em 0.25em;
touch-action: none;
height: 100%;
}
}