From 73b42c4a96d6a03a90f541fb69251da47355b19d Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Fri, 21 Mar 2025 12:52:22 +0200 Subject: [PATCH] [MM-63481] Don't substract keyboard height in Android as it was already substracted (#8697) (#8707) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * don't substract keyboard height in Android as it was already substracted (cherry picked from commit 60d4e9522957e1d314b72a976c4b50f1c55c01dc) Co-authored-by: Guillermo VayĆ” --- app/components/post_draft/post_draft.tsx | 4 ++-- app/hooks/autocomplete.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/components/post_draft/post_draft.tsx b/app/components/post_draft/post_draft.tsx index dd7343e52..657657574 100644 --- a/app/components/post_draft/post_draft.tsx +++ b/app/components/post_draft/post_draft.tsx @@ -52,6 +52,7 @@ function PostDraft({ const [postInputTop, setPostInputTop] = useState(0); const [isFocused, setIsFocused] = useState(false); const keyboardHeight = useKeyboardHeight(); + const kbHeight = Platform.OS === 'ios' ? keyboardHeight : 0; // useKeyboardHeight is already deducting the keyboard height on Android const headerHeight = useDefaultHeaderHeight(); const serverUrl = useServerUrl(); @@ -61,9 +62,8 @@ function PostDraft({ setCursorPosition(message.length); }, [channelId, rootId]); - const autocompletePosition = AUTOCOMPLETE_ADJUST + keyboardHeight + postInputTop; + const autocompletePosition = AUTOCOMPLETE_ADJUST + kbHeight + postInputTop; const autocompleteAvailableSpace = containerHeight - autocompletePosition - (isChannelScreen ? headerHeight : 0); - const [animatedAutocompletePosition, animatedAutocompleteAvailableSpace] = useAutocompleteDefaultAnimatedValues(autocompletePosition, autocompleteAvailableSpace); if (channelIsArchived || deactivatedChannel) { diff --git a/app/hooks/autocomplete.ts b/app/hooks/autocomplete.ts index 0e4e234b1..0ef95f272 100644 --- a/app/hooks/autocomplete.ts +++ b/app/hooks/autocomplete.ts @@ -10,11 +10,11 @@ export const useAutocompleteDefaultAnimatedValues = (position: number, available useEffect(() => { animatedPosition.value = position; - }, [position]); + }, [position, animatedPosition]); useEffect(() => { animatedAvailableSpace.value = availableSpace; - }, [availableSpace]); + }, [availableSpace, animatedAvailableSpace]); return [animatedPosition, animatedAvailableSpace]; };