Skip to content

Commit

Permalink
Merge pull request #35319 from MrRefactor/proposal/27866
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisl authored Feb 21, 2024
2 parents bb658c8 + 9610f7c commit 786b7ab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/styles/utils/autoCompleteSuggestion/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type ShouldPreventScrollOnAutoCompleteSuggestion from './types';

const shouldPreventScrollOnAutoCompleteSuggestion: ShouldPreventScrollOnAutoCompleteSuggestion = () => false;

export default shouldPreventScrollOnAutoCompleteSuggestion;
5 changes: 5 additions & 0 deletions src/styles/utils/autoCompleteSuggestion/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type ShouldPreventScrollOnAutoCompleteSuggestion from './types';

const shouldPreventScrollOnAutoCompleteSuggestion: ShouldPreventScrollOnAutoCompleteSuggestion = () => true;

export default shouldPreventScrollOnAutoCompleteSuggestion;
8 changes: 8 additions & 0 deletions src/styles/utils/autoCompleteSuggestion/index.website.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as Browser from '@libs/Browser';
import type ShouldPreventScrollOnAutoCompleteSuggestion from './types';

const isMobileSafari = Browser.isMobileSafari();

const shouldPreventScrollOnAutoCompleteSuggestion: ShouldPreventScrollOnAutoCompleteSuggestion = () => !isMobileSafari;

export default shouldPreventScrollOnAutoCompleteSuggestion;
3 changes: 3 additions & 0 deletions src/styles/utils/autoCompleteSuggestion/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
type ShouldPreventScrollOnAutoCompleteSuggestion = () => boolean;

export default ShouldPreventScrollOnAutoCompleteSuggestion;
7 changes: 5 additions & 2 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import CONST from '@src/CONST';
import type {Transaction} from '@src/types/onyx';
import {defaultStyles} from '..';
import type {ThemeStyles} from '..';
import shouldPreventScrollOnAutoCompleteSuggestion from './autoCompleteSuggestion';
import getCardStyles from './cardStyles';
import containerComposeStyles from './containerComposeStyles';
import FontUtils from './FontUtils';
Expand Down Expand Up @@ -790,20 +791,22 @@ function getBaseAutoCompleteSuggestionContainerStyle({left, bottom, width}: GetB
};
}

const shouldPreventScroll = shouldPreventScrollOnAutoCompleteSuggestion();

/**
* Gets the correct position for auto complete suggestion container
*/
function getAutoCompleteSuggestionContainerStyle(itemsHeight: number): ViewStyle {
'worklet';

const borderWidth = 2;
const height = itemsHeight + 2 * CONST.AUTO_COMPLETE_SUGGESTER.SUGGESTER_INNER_PADDING;
const height = itemsHeight + 2 * CONST.AUTO_COMPLETE_SUGGESTER.SUGGESTER_INNER_PADDING + (shouldPreventScroll ? borderWidth : 0);

// The suggester is positioned absolutely within the component that includes the input and RecipientLocalTime view (for non-expanded mode only). To position it correctly,
// we need to shift it by the suggester's height plus its padding and, if applicable, the height of the RecipientLocalTime view.
return {
overflow: 'hidden',
top: -(height + CONST.AUTO_COMPLETE_SUGGESTER.SUGGESTER_PADDING + borderWidth),
top: -(height + CONST.AUTO_COMPLETE_SUGGESTER.SUGGESTER_PADDING + (shouldPreventScroll ? 0 : borderWidth)),
height,
minHeight: CONST.AUTO_COMPLETE_SUGGESTER.SUGGESTION_ROW_HEIGHT,
};
Expand Down

0 comments on commit 786b7ab

Please sign in to comment.