-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Make autocomplete work with entity ids #51633
base: main
Are you sure you want to change the base?
Make autocomplete work with entity ids #51633
Conversation
e63486c
to
533131a
Compare
533131a
to
1e9929d
Compare
2cc15d1
to
e3e559b
Compare
@rayane-djouah Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
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.
LGTM
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.
|
||
.filter((details): details is NonNullable<PersonalDetails> => !!(details && details?.login)) | ||
.map((details) => ({ | ||
name: details.login ?? '', |
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.
We might wanna use displayName ?? login
here since I imagine most people would search based on names, not emails
return; | ||
filteredAutocompleteSuggestions = filteredChats.map((chat) => ({ | ||
filterKey: CONST.SEARCH.SYNTAX_FILTER_KEYS.IN, | ||
text: chat.text ?? '', |
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.
I think this is ok for now, but we might have to add some more details to the name to help users differentiate multiple reports with the same name, e.g. admin
rooms
const queryString = SearchQueryUtils.buildSearchQueryString(standardizedQuery); | ||
Navigation.navigate(ROUTES.SEARCH_CENTRAL_PANE.getRoute({query: queryString})); | ||
|
||
const computeNodeValueFn = SearchQueryUtils.getUpdatedAmountValue; |
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.
NAB this variable seems unnecessary, we can just pass the param inline
const computeNodeValueFn = SearchQueryUtils.getUpdatedAmountValue; | |
const computeNodeValueFn = SearchQueryUtils.getUpdatedAmountValue; |
); | ||
|
||
const onAutocompleteSuggestionClick = (autocompleteKey: string, autocompleteId: string) => { |
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.
const onAutocompleteSuggestionClick = (autocompleteKey: string, autocompleteId: string) => { | |
const onAutocompleteSuggestionClick = (autocompleteKey: string, autocompleteID: string) => { |
import type {SearchAutocompleteQueryRange} from '@components/Search/types'; | ||
import * as parser from '@libs/SearchParser/autocompleteParser'; | ||
|
||
type SubstitutionEntry = {value: string}; |
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.
Do we need the value key here? AFAIK we always have the map as {[filterKey:typedValue]: {value: [id]}}
. Could we simplify it to {[filterKey:typedValue]: [id]}
?
type SubstitutionEntry = {value: string}; | |
type SubstitutionEntry = {value: string}; |
@luacmartins I definitely think we should distinguish those somehow. Right now that list is basically unusable. There's a million ways we could do that, here are a few ideas: I think I lean towards the simple dot separator pattern: |
^ is being discussed here |
Details
from
,to
,in
,tax
,cardID
)SearchRouter
,SearchPageHeader
will still work using old code; I will make this autocomplete work also on Results page inSearchPageHeader
but in a separate PR. Doing it in here would make this PR grow way over 1k locDetailed autocomplete description
test from:john@expensify.com
, then when submitting we would run a function standardizeQueryJSON to traverse the parsed tree and substitue all plain text values with id values for specific filters. (this helper fn did the job: https://github.com/Expensify/App/blob/main/src/libs/SearchQueryUtils.ts#L169)in:adm
into my autocomplete I get more than 5 different rooms all named#admins
. Previous solution couldn't handle a string like thisin:#admins hello
because we don't know which room#admins
room it might be. This is the source of bug [HOLD Search autocomplete][Search v2.5] - Input shows report ID instead of report name when selecting "Search in" #50976.new implementation
substitutionsMap
objectstring
that user sees in his query with anautocompleteID
of the entity that can be stored in URL and sent to backend; these ids can beaccountID
for a user orreportID
for chat/room/report, and some other ids for tags and cardsstandardizeQueryJSON
function can soon be removed, but this mechanism described above now only works forSearchRouter
, whereas input insideSearchHeaderPage
still uses the old substitution mechanism, and thus needs the functiongetQueryWithSubstitutions
andgetUpdatedSubstitutionsMap
should help understand thisFixed Issues
$ #50976
$ #50947
$ #50944
$ #50943
PROPOSAL:
Tests
cmd +k
shortcutfrom:...
,to:...
,cardID:...
andtax:...
Offline tests
QA Steps
cmd +k
shortcutfrom:...
,to:...
,cardID:...
andtax:...
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
rec-autocomplete-andr.mp4
Android: mWeb Chrome
iOS: Native
rec-autocomplete-ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
rec-autocomplete-web.mp4
MacOS: Desktop