-
Notifications
You must be signed in to change notification settings - Fork 2
[906] chore: clear search results when focused outside the Search widget #909
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
[906] chore: clear search results when focused outside the Search widget #909
Conversation
🦋 Changeset detectedLatest commit: 76150bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Visit the preview URL for this PR (updated for commit 76150bb): https://react-kitchen-sink-dev--pr909-906-clear-search-wid-72atvv6i.web.app (expires Wed, 27 Nov 2024 20:57:07 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9 |
@@ -227,6 +227,7 @@ export const Search: React.FC<SearchProps> = ({ | |||
renderLabel(label, labelValue) | |||
} | |||
notFoundContent={notFoundContentRenderer} | |||
onBlur={handleClear} |
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.
shouldn't we expose the onBlur property with EnsembleAction instead of clearing the results.
Clearing means user will lost the previously searched results, this might solve the current problem, but not a general use case
CC: @evshi
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.
The issue we are trying to solve here is if the value is emptied, then the search results should also be emptied. It doesn't necessarily have anything to do with blur
. Ticket for context https://atlashealth.atlassian.net/browse/TRINITY-1461
@justEhmadSaeed what is clearing the search input 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.
@evshi setSearchValue(null)
is clearing the input value as that's the default behavior of the Select comp. of antd
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.
In that case, we should add an effect/fix the effect that syncs the search results with the value. If the value was set to be null, the search results should get cleared @justEhmadSaeed
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.
@evshi updated the PR
useEffect(() => { | ||
if (!searchValue) { | ||
setHasCleared(true); | ||
} | ||
}, [searchValue]); |
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 don't think we need hasCleared? I think if you use isEmpty
instead of isNil
and isNull
then we can get rid of the extra flag.
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.
@evshi yeah if we modify the condition to return an empty array if either searchValue is empty or hasCleared is true
Describe your changes
#906
Screenshots [Optional]
Screen.Recording.2024-11-20.at.5.10.23.PM.mov
Issue ticket number and link
Closes #
Checklist before requesting a review
pnpm changeset add