Skip to content

Commit

Permalink
Ensure non-empty result set on enter (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
terror authored Jan 9, 2025
1 parent fa70054 commit a8a48b4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion client/src/components/CourseSearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,15 @@ export const CourseSearchBar = ({
);
}

if (selectedIndex > -1 && event.key === 'Enter') {
if (selectedIndex > -1 && event.key === 'Enter' && length !== 0) {
navigate(
selectedIndex < results.courses.length
? `/course/${courseIdToUrlParam(results.courses[selectedIndex]._id)}`
: `/instructor/${encodeURIComponent(
results.instructors[selectedIndex - results.courses.length]
)}`
);

if (onResultClick) {
onResultClick();
event.currentTarget.blur();
Expand Down

0 comments on commit a8a48b4

Please sign in to comment.