Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d0891e0
show search button
bernhardoj Jun 14, 2026
f35bba7
rework search input to be a keyword search only
bernhardoj Jun 14, 2026
74eef38
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 14, 2026
587eb7a
remove keyword filter when pressing clear
bernhardoj Jun 14, 2026
4b20314
remove unused type
bernhardoj Jun 14, 2026
89865db
fix test
bernhardoj Jun 14, 2026
60427c5
lint
bernhardoj Jun 14, 2026
28757c1
remove unused type
bernhardoj Jun 14, 2026
720f467
lint
bernhardoj Jun 14, 2026
70ceeaa
remove unused import
bernhardoj Jun 15, 2026
eb40f27
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 15, 2026
92e0c53
fix extra spacing
bernhardoj Jun 15, 2026
c79f232
move individual style to styles
bernhardoj Jun 15, 2026
05cd75d
lint
bernhardoj Jun 15, 2026
0a0bca2
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 17, 2026
16b91a8
fix search filter bar skeleton styling
bernhardoj Jun 17, 2026
d78a385
change clear icon size to 16
bernhardoj Jun 17, 2026
0b1d2b3
implement keyword escaping in search queries to prevent filter syntax…
bernhardoj Jun 17, 2026
0c52112
populate initial search router input value from the current query on …
bernhardoj Jun 17, 2026
b3bc0c8
do the escaping on the deeper function
bernhardoj Jun 17, 2026
706f66f
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 17, 2026
e64c58f
merge with main leftover
bernhardoj Jun 17, 2026
f1f5a7c
Revert "merge with main leftover"
bernhardoj Jun 17, 2026
de2661d
restore previous change
bernhardoj Jun 17, 2026
1b2c955
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 18, 2026
b8ff0b2
add back the raw query logic
bernhardoj Jun 19, 2026
e709e9b
change the position
bernhardoj Jun 19, 2026
b92c474
show the current query on the search router
bernhardoj Jun 19, 2026
7cc73c8
fix test
bernhardoj Jun 19, 2026
d2d2c9b
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 20, 2026
6765f19
restore previous change
bernhardoj Jun 20, 2026
8538ba4
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 25, 2026
87b484c
update comment
bernhardoj Jun 25, 2026
c4ea580
improve the syntax regex
bernhardoj Jun 25, 2026
eeae3d9
update test
bernhardoj Jun 25, 2026
6260b74
fix single keyword wrapped with quote is separated into 2 keywords
bernhardoj Jun 25, 2026
50c8acc
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 25, 2026
d8c8b66
remove unused prop
bernhardoj Jun 25, 2026
84745b4
readd removed var
bernhardoj Jun 25, 2026
78fcf5c
update regex
bernhardoj Jun 25, 2026
c186140
don't show query in search input when apply keyword
bernhardoj Jun 25, 2026
aaacc4d
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 25, 2026
44b383c
remove unused prop
bernhardoj Jun 25, 2026
2995b27
revert wrong changes
bernhardoj Jun 25, 2026
b953fd5
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj Jun 25, 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useOnyx from '@hooks/useOnyx';
import useStyleUtils from '@hooks/useStyleUtils';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import {setSearchContext} from '@libs/actions/Search';
import type {SearchFilter} from '@libs/SearchUIUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -59,12 +58,7 @@ function SearchAdvancedFiltersPopup({queryJSON}: SearchAdvancedFiltersPopupProps
Date: DateFilterContentPopupWrapper,
ReportField: ReportFieldFilterContentPopupWrapper,
}}
onChange={(values) => {
updateFilterQueryParams(values);
if (values.keyword) {
setSearchContext(true);
}
}}
onChange={updateFilterQueryParams}
/>
</View>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function SearchActionsBarNarrow({queryJSON, searchResults, onSort}: SearchAction
const styles = useThemeStyles();

return (
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mr5, styles.mb4]}>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<SearchAdvancedFiltersButton queryJSON={queryJSON} />
<SearchSaveButton />
<SearchDisplayDropdownButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,30 @@ import SearchActionsBarCreateButton from './SearchActionsBarCreateButton';
import SearchAdvancedFiltersButton from './SearchAdvancedFiltersButton';
import SearchDisplayDropdownButton from './SearchDisplayDropdownButton';
import SearchFiltersBarWide from './SearchFiltersBarWide';
import SearchPageInputWide from './SearchPageInputWide';
import SearchPageInput from './SearchPageInput';
import SearchSaveButton from './SearchSaveButton';

type SearchActionsBarWideProps = {
queryJSON: SearchQueryJSON;
searchResults: OnyxEntry<SearchResults>;
handleSearch: (value: string) => void;
onSort: () => void;
};

function SearchActionsBarWide({queryJSON, searchResults, handleSearch, onSort}: SearchActionsBarWideProps) {
function SearchActionsBarWide({queryJSON, searchResults, onSort}: SearchActionsBarWideProps) {
const styles = useThemeStyles();
const {selected} = useSelectionCounts();
const hasSelectedItems = selected > 0;

return (
<View style={[styles.searchActionsBarContainer, styles.gap2, styles.mt3]}>
<View style={[styles.searchActionsBarContainer]}>
{hasSelectedItems ? (
<View style={styles.searchBulkActionsButton}>
<SearchBulkActionsButton queryJSON={queryJSON} />
</View>
) : (
<>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.pRelative, styles.w100, styles.flexWrap, styles.flexShrink1, styles.gap2, styles.zIndex10]}>
<SearchPageInputWide
queryJSON={queryJSON}
handleSearch={handleSearch}
/>
<SearchPageInput queryJSON={queryJSON} />
<SearchFiltersBarWide queryJSON={queryJSON} />
</View>
<View style={styles.filtersBar}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ type SearchPageHeaderNarrowProps = {
queryJSON: SearchQueryJSON;
shouldShowLoadingBar: boolean;
isMobileSelectionModeEnabled: boolean;
cancelSearch?: () => void;
};

function SearchPageHeaderNarrow({queryJSON, shouldShowLoadingBar = false, isMobileSelectionModeEnabled, cancelSearch}: SearchPageHeaderNarrowProps) {
function SearchPageHeaderNarrow({queryJSON, shouldShowLoadingBar = false, isMobileSelectionModeEnabled}: SearchPageHeaderNarrowProps) {
const {translate} = useLocalize();

if (isMobileSelectionModeEnabled) {
Expand All @@ -22,9 +21,7 @@ function SearchPageHeaderNarrow({queryJSON, shouldShowLoadingBar = false, isMobi
<TopBar
shouldShowLoadingBar={shouldShowLoadingBar}
breadcrumbLabel={translate('common.spend')}
shouldDisplaySearch={false}
shouldDisplayHelpButton
cancelSearch={cancelSearch}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function SearchPageHeaderWide({queryJSON}: SearchPageHeaderWideProps) {
<TopBar
shouldShowLoadingBar={false}
breadcrumbLabel={title}
shouldDisplaySearch={false}
shouldDisplayHelpButton
/>
);
Expand Down
89 changes: 89 additions & 0 deletions src/components/Search/SearchPageHeader/SearchPageInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// NOTE: This component has a static twin in SearchPageNarrow/StaticSearchPageInput.tsx
// used for fast perceived performance. If you change the UI here, verify the
// static version still looks visually identical.
import React, {useState} from 'react';
import type {SearchQueryJSON} from '@components/Search/types';
import TextInput from '@components/TextInput';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import {getKeywordQueryWithCurrentSearchContext, getQueryWithUpdatedValues, sanitizeSearchValue} from '@libs/SearchQueryUtils';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ROUTES from '@src/ROUTES';
import KeyboardUtils from '@src/utils/keyboard';

type SearchPageInputProps = {
queryJSON: SearchQueryJSON;
onFocus?: () => void;
};

function SearchPageInput({queryJSON, onFocus}: SearchPageInputProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();
const theme = useTheme();
const {shouldUseNarrowLayout} = useResponsiveLayout();

const [textInputValue, setTextInputValue] = useState('');

const keywordFilters = queryJSON.flatFilters.find((filter) => filter.key === CONST.SEARCH.SYNTAX_FILTER_KEYS.KEYWORD)?.filters ?? [];
const keywordQuery = keywordFilters.reduce((acc, keyword) => `${acc} ${sanitizeSearchValue(keyword.value.toString())}`, '').trim();
const [prevKeywordQuery, setPrevKeywordQuery] = useState('');

if (keywordQuery !== prevKeywordQuery) {
setTextInputValue(keywordQuery);
setPrevKeywordQuery(keywordQuery);
}

function submitSearch(query: string) {
const queryWithContext = getKeywordQueryWithCurrentSearchContext(query, queryJSON);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve keyword-only semantics before parsing input

When the new search-page input receives text that is valid search syntax, such as type:expense, merchant:Amazon, or amount>10, it is passed directly into getKeywordQueryWithCurrentSearchContext and then parsed by getQueryWithUpdatedValues, so the text becomes root fields or filters instead of the keyword filter this field is supposed to edit. In those cases the search can switch type/add filters or carry stale context rather than applying the entered text as a keyword; escape/wrap the user text as a keyword value (or otherwise keep explicit syntax out of this path) before composing the query.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, interesting, but this is probably out of scope. This is happening on prod too.

@trjExpensify should we handle the keyword escaping here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it out of scope? 🤔 On production right now the search input above the table accepts syntax doesn't it? Whereas this change is it to move the query search input to the top right, and make the search input above the table keyword only.

So with that, I think we probably do need to do something about this here to accommodate the desired change.

CC: @JS00001 @Expensify/design

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On prod, we can replicate it by typing the keyword in the keyword filter.

web.mp4

const updatedQuery = getQueryWithUpdatedValues(queryWithContext);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Came from this issue
We had an issue where the Amount filter value was multiplied by 100x after accepting filters
More context here


if (!updatedQuery) {
return;
}

Navigation.navigate(ROUTES.SEARCH_ROOT.getRoute({query: updatedQuery}));
}

return (
<TextInput
value={textInputValue}
onChangeText={setTextInputValue}
role={CONST.ROLE.SEARCHBOX}
placeholder={translate('search.searchPlaceholder')}
autoCapitalize="none"
autoCorrect={false}
spellCheck={false}
enterKeyHint="search"
accessibilityLabel={translate('search.searchPlaceholder')}
maxLength={CONST.SEARCH_QUERY_LIMIT}
onSubmitEditing={() => {
if (shouldUseNarrowLayout) {
KeyboardUtils.dismiss().then(() => submitSearch(textInputValue));
return;
}
submitSearch(textInputValue);
}}
containerStyles={[shouldUseNarrowLayout ? styles.flex1 : undefined]}
textInputContainerStyles={[styles.pb0, shouldUseNarrowLayout ? styles.ph3 : styles.ph2]}
inputStyle={[styles.w100, styles.lineHeightUndefined, shouldUseNarrowLayout ? undefined : styles.fontSizeLabel]}
touchableInputWrapperStyle={shouldUseNarrowLayout ? styles.searchPageInputNarrowTouchableWrapper : styles.searchPageInputWideTouchableWrapper}
clearButtonStyle={shouldUseNarrowLayout ? undefined : styles.mh0}
clearButtonIconSize={shouldUseNarrowLayout ? undefined : variables.iconSizeSmall}
placeholderTextColor={theme.textSupporting}
shouldShowClearButton={!!textInputValue}
shouldHideClearButton={false}
onClearInput={() => {
setTextInputValue('');
submitSearch('');
}}
onFocus={onFocus}
/>
);
}

export default SearchPageInput;
export type {SearchPageInputProps};

This file was deleted.

Loading
Loading