feat(search-bar): redirect to image view on enter when search maches … (#422)

* feat(search-bar): redirect to image view on enter when search maches a repo:tag

Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
LaurentiuNiculae 2024-03-01 02:07:56 -08:00 committed by GitHub
parent e2367c2a33
commit 177406df41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -132,8 +132,14 @@ function SearchSuggestion({ setSearchCurrentValue = () => {} }) {
const handleSearch = (event) => {
const { key, type } = event;
const name = event.target.value;
if (key === 'Enter' || type === 'click') {
navigate({ pathname: `/explore`, search: createSearchParams({ search: inputValue || '' }).toString() });
if (name?.includes(':')) {
const splitName = name.split(':');
navigate(`/image/${encodeURIComponent(splitName[0])}/tag/${splitName[1]}`);
} else {
navigate({ pathname: `/explore`, search: createSearchParams({ search: inputValue || '' }).toString() });
}
}
};