Skip to content

Commit

Permalink
feat(search-bar): redirect to image view on enter when search maches … (
Browse files Browse the repository at this point in the history
#422)

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

Signed-off-by: Laurentiu Niculae <[email protected]>
  • Loading branch information
laurentiuNiculae authored Mar 1, 2024
1 parent e2367c2 commit 177406d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/components/Header/SearchSuggestion.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
}
}
};

Expand Down

0 comments on commit 177406d

Please sign in to comment.