Repository navigation
Rework search input to be a keyword search only #93543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JS00001
merged 45 commits into
Expensify:main
from
bernhardoj:feat/92924-rework-search-input
Jun 25, 2026
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
d0891e0
show search button
bernhardoj f35bba7
rework search input to be a keyword search only
bernhardoj 74eef38
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj 587eb7a
remove keyword filter when pressing clear
bernhardoj 4b20314
remove unused type
bernhardoj 89865db
fix test
bernhardoj 60427c5
lint
bernhardoj 28757c1
remove unused type
bernhardoj 720f467
lint
bernhardoj 70ceeaa
remove unused import
bernhardoj eb40f27
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj 92e0c53
fix extra spacing
bernhardoj c79f232
move individual style to styles
bernhardoj 05cd75d
lint
bernhardoj 0a0bca2
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj 16b91a8
fix search filter bar skeleton styling
bernhardoj d78a385
change clear icon size to 16
bernhardoj 0b1d2b3
implement keyword escaping in search queries to prevent filter syntax…
bernhardoj 0c52112
populate initial search router input value from the current query on …
bernhardoj b3bc0c8
do the escaping on the deeper function
bernhardoj 706f66f
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj e64c58f
merge with main leftover
bernhardoj f1f5a7c
Revert "merge with main leftover"
bernhardoj de2661d
restore previous change
bernhardoj 1b2c955
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj b8ff0b2
add back the raw query logic
bernhardoj e709e9b
change the position
bernhardoj b92c474
show the current query on the search router
bernhardoj 7cc73c8
fix test
bernhardoj d2d2c9b
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj 6765f19
restore previous change
bernhardoj 8538ba4
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj 87b484c
update comment
bernhardoj c4ea580
improve the syntax regex
bernhardoj eeae3d9
update test
bernhardoj 6260b74
fix single keyword wrapped with quote is separated into 2 keywords
bernhardoj 50c8acc
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj d8c8b66
remove unused prop
bernhardoj 84745b4
readd removed var
bernhardoj 78fcf5c
update regex
bernhardoj c186140
don't show query in search input when apply keyword
bernhardoj aaacc4d
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj 44b383c
remove unused prop
bernhardoj 2995b27
revert wrong changes
bernhardoj b953fd5
Merge branch 'main' into feat/92924-rework-search-input
bernhardoj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/components/Search/SearchPageHeader/SearchPageInput.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| const updatedQuery = getQueryWithUpdatedValues(queryWithContext); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Came from this issue |
||
|
|
||
| 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}; | ||
94 changes: 0 additions & 94 deletions
94
src/components/Search/SearchPageHeader/SearchPageInputNarrow.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the new search-page input receives text that is valid search syntax, such as
type:expense,merchant:Amazon, oramount>10, it is passed directly intogetKeywordQueryWithCurrentSearchContextand then parsed bygetQueryWithUpdatedValues, 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 👍 / 👎.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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