Skip to content
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

Fix browser nav & remove the need to double-ENTER on the searchbar #298

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
6 changes: 5 additions & 1 deletion src/pages/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ export const Dashboard: NextPage = () => {
professorSearchTerms.map((term) => {
str += searchQueryLabel(term) + ', ';
});
str =
str.lastIndexOf(', ') === str.length - 2
? str.substring(0, str.lastIndexOf(', ')) + ' - '
: str;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this line. Is there a more efficient way?
It also has the fun property that if str is somehow length 1, the if condition is true -> it tries the substring

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't str always empty until anything is added to it?
And running str.slice(0, -2) on any empty string causes no error and just returns an empty string.
So why not just str = str.slice(0, -2);

When is str ever length 1 tho? It's either nothing or it has a search term plus ", " added to it. Either way, I think the above solution works

setPageTitle(str);
}
TyHil marked this conversation as resolved.
Show resolved Hide resolved

Expand Down Expand Up @@ -780,7 +784,7 @@ export const Dashboard: NextPage = () => {
return (
<>
<Head>
<title>{pageTitle + ' - UTD TRENDS'}</title>
<title>{'Results - ' + pageTitle + 'UTD TRENDS'}</title>
<link
rel="canonical"
href="https://trends.utdnebula.com/dashboard"
Expand Down
Loading