Skip to content

Commit

Permalink
Apply workaround for suggestion box positioning on android
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRefactor committed Aug 5, 2024
1 parent d27bee0 commit 422f31b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/AutoCompleteSuggestions/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React, {useEffect} from 'react';
import {Platform} from 'react-native';
import useKeyboardState from '@hooks/useKeyboardState';
import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
import useStyleUtils from '@hooks/useStyleUtils';
import useWindowDimensions from '@hooks/useWindowDimensions';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import StatusBar from '@libs/StatusBar';
import CONST from '@src/CONST';
import AutoCompleteSuggestionsPortal from './AutoCompleteSuggestionsPortal';
import type {AutoCompleteSuggestionsProps, MeasureParentContainerAndCursor} from './types';
Expand Down Expand Up @@ -95,7 +97,11 @@ function AutoCompleteSuggestions<TSuggestion>({measureParentContainerAndReportCu
: xCoordinatesOfCursor;
const contentMaxHeight = measureHeightOfSuggestionRows(suggestionsLength, true);
const contentMinHeight = measureHeightOfSuggestionRows(suggestionsLength, false);
let bottomValue = windowHeight - (cursorCoordinates.y - scrollValue + y) - keyboardHeight;
// This is a workaround to fix suggestion box positioning on android devices, to be removed with react-native 0.75
let bottomValue =
Platform.OS === 'android'
? windowHeight - (cursorCoordinates.y - scrollValue + y) - keyboardHeight - (StatusBar.currentHeight ?? 0) - 20
: windowHeight - (cursorCoordinates.y - scrollValue + y) - keyboardHeight;
const widthValue = isSmallScreenWidth ? width : CONST.AUTO_COMPLETE_SUGGESTER.BIG_SCREEN_SUGGESTION_WIDTH;

const isEnoughSpaceToRenderMenuAboveForBig = isEnoughSpaceToRenderMenuAboveCursor({y, cursorCoordinates, scrollValue, contentHeight: contentMaxHeight, topInset});
Expand Down

0 comments on commit 422f31b

Please sign in to comment.