-
Notifications
You must be signed in to change notification settings - Fork 392
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
CB-3753-1809-fr-add-field-hints-in-the-filter-field #3151
base: devel
Are you sure you want to change the base?
CB-3753-1809-fr-add-field-hints-in-the-filter-field #3151
Conversation
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.
👍🏻
interface InputAutocompleteOptions { | ||
sourceHints: InputAutocompleteProposal[]; | ||
matchStrategy?: InputAutocompleteStrategy; | ||
filter?: (suggestion: InputAutocompleteProposal, lastWord?: string) => boolean; |
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 believe predicate
is more descriptive word for that prop, then filter.
const words = this.input?.split(' '); | ||
|
||
if (!isNotNullDefined(words) || !isNotNullDefined(cursorPosition) || !isNotNullDefined(this.currentWord)) { |
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 to check words and cursor here if currentWord getter should return falsy value if there is no words or cursorPosition?
(this.matchStrategy === 'startsWith' && | ||
values.some(value => isNotNullDefined(this.currentWord) && value.startsWith(this.currentWord))) || | ||
(this.matchStrategy === 'contains' && values.some(value => isNotNullDefined(this.currentWord) && value.includes(this.currentWord))) || | ||
(this.matchStrategy === 'fuzzy' && | ||
values.some(value => isNotNullDefined(this.currentWord) && isFuzzySearchable(this.currentWord, value))) | ||
); | ||
}) |
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.
(this.matchStrategy === 'startsWith' && | |
values.some(value => isNotNullDefined(this.currentWord) && value.startsWith(this.currentWord))) || | |
(this.matchStrategy === 'contains' && values.some(value => isNotNullDefined(this.currentWord) && value.includes(this.currentWord))) || | |
(this.matchStrategy === 'fuzzy' && | |
values.some(value => isNotNullDefined(this.currentWord) && isFuzzySearchable(this.currentWord, value))) | |
); | |
}) | |
const isMatch = () => { | |
const { matchStrategy, currentWord } = this; | |
if (!isNotNullDefined(currentWord)) { | |
return false; | |
} | |
const matchFunctions: { [key: InputAutocompleteStrategy]: (value: string) => boolean } = { | |
startsWith: value => value.startsWith(currentWord), | |
contains: value => value.includes(currentWord), | |
fuzzy: value => isFuzzySearchable(currentWord, value), | |
}; | |
return values.some(matchFunctions[matchStrategy]); | |
}; |
Maybe like that? And we checked thus.currentWord just above, so maybe we can skip this check:
if (!isNotNullDefined(currentWord)) {
return false;
}
No description provided.