Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
026c099
fix: keep Search Router results above offline indicator
nabi-ebrahimi Jul 28, 2026
95ad39c
fix: constrain Search Router height when keyboard is open
nabi-ebrahimi Jul 28, 2026
a578c4c
Merge branch 'main' into 97182-search-router-offline-scroll
nabi-ebrahimi Jul 28, 2026
c69f546
fix: scale Spend navigation context for large fonts
nabi-ebrahimi Jul 28, 2026
f13bab4
fix: prevent Search Router results from overflowing keyboard padding
nabi-ebrahimi Jul 28, 2026
09226ae
Revert offline Search Router scroll workaround
nabi-ebrahimi Jul 29, 2026
7963b4c
Merge branch 'main' into 97182-search-router-offline-scroll
nabi-ebrahimi Jul 29, 2026
442ac01
fix: constrain native Search Router above keyboard
nabi-ebrahimi Jul 29, 2026
025fbea
fix: normalize Search Router keyboard height
nabi-ebrahimi Jul 29, 2026
db09851
fix: scope Search Router height cap to offline mode
nabi-ebrahimi Jul 29, 2026
1964fdd
fix: reserve space for Search Router offline indicator
nabi-ebrahimi Jul 29, 2026
76da89e
docs: explain native Search Router height calculation
nabi-ebrahimi Jul 29, 2026
c11ea83
refactor: use StyleUtils for Search Router max height
nabi-ebrahimi Jul 29, 2026
0a4887d
Merge branch 'main' into 97182-search-router-offline-scroll
nabi-ebrahimi Jul 29, 2026
cdcf87c
refactor: clarify Search Router keyboard height calculation
nabi-ebrahimi Jul 31, 2026
5b49ac9
docs: clarify Search Router height constraint
nabi-ebrahimi Jul 31, 2026
7bfb2c5
test: cover Search Router available height calculation
nabi-ebrahimi Jul 31, 2026
10d3495
test: cover Search Router offline indicator padding
nabi-ebrahimi Jul 31, 2026
68f00f5
Merge branch 'main' into 97182-search-router-offline-scroll
nabi-ebrahimi Aug 3, 2026
424fe11
refactor: clarify offline keyboard height constraint
nabi-ebrahimi Aug 3, 2026
0b53a71
test: remove redundant padding type assertion
nabi-ebrahimi Aug 3, 2026
c7769cc
test: explain Search Router padding snapshot selection
nabi-ebrahimi Aug 3, 2026
1f60a6e
Merge branch 'main' into 97182-search-router-offline-scroll
nabi-ebrahimi Aug 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/Search/SearchAutocompleteList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import SelectionListWithSections from '@components/SelectionList/SelectionListWi
import type {Section, SelectionListWithSectionsHandle} from '@components/SelectionList/SelectionListWithSections/types';

import useAutocompleteSuggestions from '@hooks/useAutocompleteSuggestions';
import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useDebounce from '@hooks/useDebounce';
import useDebouncedAccessibilityAnnouncement from '@hooks/useDebouncedAccessibilityAnnouncement';
Expand Down Expand Up @@ -186,6 +187,10 @@ function SearchAutocompleteList({
const styles = useThemeStyles();
const {translate, localeCompare} = useLocalize();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const contentContainerStyle = useBottomSafeSafeAreaPaddingStyle({
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
addOfflineIndicatorBottomSafeAreaPadding: true,
style: styles.pb2,
});

const [betas] = useOnyx(ONYXKEYS.BETAS);
const feedKeysWithCards = useFeedKeysWithAssignedCards();
Expand Down Expand Up @@ -730,7 +735,7 @@ function SearchAutocompleteList({
style={{
containerStyle: [styles.mh100],
listStyle: [styles.ph2, styles.overscrollBehaviorContain],
contentContainerStyle: styles.pb2,
contentContainerStyle,
listItemWrapperStyle: [styles.pr0, styles.pl0],
sectionTitleStyles: styles.mhn2,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,56 @@ import ScreenWrapper from '@components/ScreenWrapper';
import SearchRouter from '@components/Search/SearchRouter/SearchRouter';
import {useSearchRouterActions, useSearchRouterState} from '@components/Search/SearchRouter/SearchRouterContext';

import useKeyboardState from '@hooks/useKeyboardState';
import useNetwork from '@hooks/useNetwork';
import useSafeAreaInsets from '@hooks/useSafeAreaInsets';
import useSafeAreaPaddings from '@hooks/useSafeAreaPaddings';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';

import getKeyboardHeight from '@libs/getKeyboardHeight';

import React from 'react';
import {View} from 'react-native';

type GetAvailableHeightParams = {
isKeyboardOverlapping: boolean;
keyboardHeight: number;
keyboardActiveHeight: number;
bottomInset: number;
windowHeight: number;
paddingTop: number;
};

function getAvailableHeight({isKeyboardOverlapping, keyboardHeight, keyboardActiveHeight, bottomInset, windowHeight, paddingTop}: GetAvailableHeightParams): number | undefined {
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
const measuredKeyboardHeight = keyboardHeight || getKeyboardHeight(keyboardActiveHeight, bottomInset);
const effectiveKeyboardHeight = isKeyboardOverlapping ? measuredKeyboardHeight : 0;
return effectiveKeyboardHeight ? Math.max(windowHeight - effectiveKeyboardHeight - paddingTop, 0) : undefined;
}

function SearchRouterPage() {
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
const {closeSearchRouter} = useSearchRouterActions();
const {isSearchRouterDisplayed} = useSearchRouterState();
const {isKeyboardActive, keyboardHeight, keyboardActiveHeight} = useKeyboardState();
const {isOffline} = useNetwork();
const {paddingTop} = useSafeAreaPaddings();
const {bottom} = useSafeAreaInsets();
const {windowHeight} = useWindowDimensions();
const StyleUtils = useStyleUtils();
const styles = useThemeStyles();
const shouldConstrainForOfflineKeyboard = isOffline && isKeyboardActive;
// Keep the router between the top safe area and the keyboard; ScreenWrapper and the
// list already handle bottom safe-area and offline-indicator spacing.
// Clamp to zero so transient dimensions during animation never produce a negative height.
const availableHeight = getAvailableHeight({
isKeyboardOverlapping: shouldConstrainForOfflineKeyboard,
keyboardHeight,
keyboardActiveHeight,
bottomInset: bottom,
windowHeight,
paddingTop,
});

return (
<ScreenWrapper
Expand All @@ -16,13 +61,16 @@ function SearchRouterPage() {
includePaddingTop
includeSafeAreaPaddingBottom
>
<SearchRouter
onRouterClose={closeSearchRouter}
shouldHideInputCaret={false}
isSearchRouterDisplayed={isSearchRouterDisplayed}
/>
<View style={[styles.flex1, availableHeight !== undefined && StyleUtils.getMaximumHeight(availableHeight)]}>
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
<SearchRouter
onRouterClose={closeSearchRouter}
shouldHideInputCaret={false}
isSearchRouterDisplayed={isSearchRouterDisplayed}
/>
</View>
</ScreenWrapper>
);
}

export default SearchRouterPage;
export {getAvailableHeight};
80 changes: 72 additions & 8 deletions tests/unit/SearchAutocompleteListTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import {act, fireEvent, render, screen, waitFor} from '@testing-library/react-na

import {LocaleContextProvider} from '@components/LocaleContextProvider';
import OnyxListItemProvider from '@components/OnyxListItemProvider';
import ScreenWrapperOfflineIndicatorContext from '@components/ScreenWrapper/ScreenWrapperOfflineIndicatorContext';
import type {SearchQueryItem} from '@components/Search/SearchList/ListItem/SearchQueryListItem';
import SearchRouter from '@components/Search/SearchRouter/SearchRouter';
import Text from '@components/Text';

import type {PrivateIsArchivedMap} from '@hooks/usePrivateIsArchivedMap';

import {setHasRadio} from '@libs/NetworkState';
import type * as OptionsListUtilsModule from '@libs/OptionsListUtils';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import {createFilteredOptionList} from '@libs/OptionsListUtils';
Expand All @@ -21,8 +23,10 @@ import ROUTES from '@src/ROUTES';
import type {PersonalDetails, Report} from '@src/types/onyx';

import type * as NativeNavigation from '@react-navigation/native';
import type ReactNative from 'react-native';

import React from 'react';
import {StyleSheet} from 'react-native';
import Onyx from 'react-native-onyx';

import createCollection from '../utils/collections/createCollection';
Expand All @@ -32,6 +36,25 @@ import * as TestHelper from '../utils/TestHelper';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
import wrapOnyxWithWaitForBatchedUpdates from '../utils/wrapOnyxWithWaitForBatchedUpdates';

const mockFlashListContentContainerStyles: Array<React.ComponentProps<typeof ReactNative.FlatList>['contentContainerStyle']> = [];
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved

jest.mock('@shopify/flash-list', () => {
const RN = jest.requireActual<typeof ReactNative>('react-native');
return {
FlashList: ({data, contentContainerStyle, ...props}: React.ComponentProps<typeof RN.FlatList>) => {
mockFlashListContentContainerStyles.push(contentContainerStyle);
return (
<RN.FlatList
data={data}
contentContainerStyle={contentContainerStyle}
{...props}
initialNumToRender={data?.length}
/>
);
},
};
});

jest.mock('lodash/debounce', () =>
jest.fn((fn: Record<string, jest.Mock>) => {
// eslint-disable-next-line no-param-reassign
Expand Down Expand Up @@ -145,7 +168,12 @@ const mockedReports = getMockedReports(10);
const mockedBetas = Object.values(CONST.BETAS);
const mockedPersonalDetails = getMockedPersonalDetails(10);
const EMPTY_PRIVATE_IS_ARCHIVED_MAP: PrivateIsArchivedMap = {};
const mockedOptions = createFilteredOptionList(mockedPersonalDetails, mockedReports, undefined, EMPTY_PRIVATE_IS_ARCHIVED_MAP, undefined, {conciergeReportID: undefined, isSearching: true});
const mockedOptions = createFilteredOptionList(mockedPersonalDetails, mockedReports, undefined, EMPTY_PRIVATE_IS_ARCHIVED_MAP, undefined, {
conciergeReportID: undefined,
isSearching: true,
});
const OFFLINE_INDICATOR_SAFE_AREA_CONTEXT_ENABLED = {addSafeAreaPadding: true};
const OFFLINE_INDICATOR_SAFE_AREA_CONTEXT_DISABLED = {addSafeAreaPadding: false};

const mockOnClose = jest.fn((afterClose?: () => void) => {
afterClose?.();
Expand All @@ -159,14 +187,18 @@ const fakeRecentReports = [
{reportID: '103', keyForList: '103', text: 'Charlie Report', alternateText: 'charlie alt', lastMessageText: 'hey'},
];

function SearchRouterWrapper({isSearchRouterDisplayed}: {isSearchRouterDisplayed?: boolean}) {
function SearchRouterWrapper({isSearchRouterDisplayed, addOfflineIndicatorSafeAreaPadding}: {isSearchRouterDisplayed?: boolean; addOfflineIndicatorSafeAreaPadding?: boolean}) {
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
return (
<ComposeProviders components={[OnyxListItemProvider, LocaleContextProvider]}>
<SearchRouter
onRouterClose={mockOnClose}
isSearchRouterDisplayed={isSearchRouterDisplayed}
/>
</ComposeProviders>
<ScreenWrapperOfflineIndicatorContext.Provider
value={addOfflineIndicatorSafeAreaPadding ? OFFLINE_INDICATOR_SAFE_AREA_CONTEXT_ENABLED : OFFLINE_INDICATOR_SAFE_AREA_CONTEXT_DISABLED}
>
<ComposeProviders components={[OnyxListItemProvider, LocaleContextProvider]}>
<SearchRouter
onRouterClose={mockOnClose}
isSearchRouterDisplayed={isSearchRouterDisplayed}
/>
</ComposeProviders>
</ScreenWrapperOfflineIndicatorContext.Provider>
);
}

Expand Down Expand Up @@ -204,6 +236,7 @@ describe('SearchAutocompleteList', () => {
});

afterEach(async () => {
setHasRadio(true);
await act(async () => {
await Onyx.clear();
});
Expand Down Expand Up @@ -251,6 +284,37 @@ describe('SearchAutocompleteList', () => {
});
});

it('should add offline indicator clearance to the list content', async () => {
mockUseNavigationSuggestions.mockReturnValue([
{
text: 'Go to Inbox',
keyForList: 'inbox',
searchItemType: CONST.SEARCH.SEARCH_ROUTER_ITEM_TYPE.NAVIGATE,
action: jest.fn(),
},
]);
mockFlashListContentContainerStyles.length = 0;
render(<SearchRouterWrapper addOfflineIndicatorSafeAreaPadding />);
await flushAllUpdates();

const getContentPaddingBottom = () => {
// FlashList records a style per render; use the latest numeric bottom padding.
return mockFlashListContentContainerStyles
.map((contentContainerStyle) => StyleSheet.flatten(contentContainerStyle)?.paddingBottom)
Comment thread
nabi-ebrahimi marked this conversation as resolved.
Resolved
.findLast((paddingBottom) => typeof paddingBottom === 'number');
};
const onlinePaddingBottom = getContentPaddingBottom();

if (typeof onlinePaddingBottom !== 'number') {
throw new Error('Expected the Search Router list to have numeric bottom padding');
}

act(() => setHasRadio(false));
await flushAllUpdates();

expect(getContentPaddingBottom()).toBe(onlinePaddingBottom + CONST.OFFLINE_INDICATOR_HEIGHT);
});

it('should display Recent searches section when query is empty and recent searches exist', async () => {
const timestampOne = '2024-01-01T00:00:00';
const timestampTwo = '2024-01-02T00:00:00';
Expand Down
55 changes: 55 additions & 0 deletions tests/unit/SearchRouterPageTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {getAvailableHeight} from '@components/Search/SearchRouter/SearchRouterPage/index.native';

describe('SearchRouterPage', () => {
it('does not constrain the height when the keyboard is not overlapping', () => {
expect(
getAvailableHeight({
isKeyboardOverlapping: false,
keyboardHeight: 300,
keyboardActiveHeight: 300,
bottomInset: 0,
windowHeight: 800,
paddingTop: 20,
}),
).toBeUndefined();
});

it('uses the settled keyboard height', () => {
expect(
getAvailableHeight({
isKeyboardOverlapping: true,
keyboardHeight: 300,
keyboardActiveHeight: 350,
bottomInset: 0,
windowHeight: 800,
paddingTop: 20,
}),
).toBe(480);
});

it('falls back to the active keyboard height during animation', () => {
expect(
getAvailableHeight({
isKeyboardOverlapping: true,
keyboardHeight: 0,
keyboardActiveHeight: 300,
bottomInset: 0,
windowHeight: 800,
paddingTop: 20,
}),
).toBe(480);
});

it('clamps transient negative heights to zero', () => {
expect(
getAvailableHeight({
isKeyboardOverlapping: true,
keyboardHeight: 500,
keyboardActiveHeight: 500,
bottomInset: 0,
windowHeight: 400,
paddingTop: 20,
}),
).toBe(0);
});
});
Loading