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

Conversation

AbhiramTadepalli
Copy link
Contributor

Browser Nav:

  • More intuitive (normal expectation) browser history behavior: every new search triggers an entry on the history stack
  • Dynamic Page titles: in the format "Result - CS 1200, John Cole - UTD TRENDS"

Searchbar ENTER:

  • Previous Behavior: Type cs1200, click enter to add the autocomplete suggestion to the searchbar, then click again
  • New Behavior: Type cs1200, click enter -> Adds the autocomplete suggestion to the searchbar AND triggers the search without an additional keypress
    • Note: typing cs1200 and then clicking space allows you to add the autocomplete to the searchbar's searchqueries, but does not trigger a new search

Copy link

vercel bot commented Nov 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
utd-trends ❌ Failed (Inspect) Nov 10, 2024 8:00am

@AbhiramTadepalli
Copy link
Contributor Author

@TyHil could you look over these questions?

@TyHil
Copy link
Member

TyHil commented Nov 8, 2024

Idk what questions but I like all of these changes. What do you think of the commit I made to do the page title without an extra state?

Also, intentional choice to capitalize UTD TRENDS?

@@ -181,6 +165,7 @@ const SearchBar = ({
if (newValue.length) setErrorTooltip(false); //close the tooltip if there is at least 1 valid search term
setValue(newValue);
onChange_internal(newValue);
Copy link
Member

Choose a reason for hiding this comment

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

Also, I think we can remove this line since the new line below covers its functionality

Copy link
Contributor Author

@AbhiramTadepalli AbhiramTadepalli left a comment

Choose a reason for hiding this comment

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

@TyHil sorry they were unpublished

@@ -165,6 +165,7 @@ const SearchBar = ({
if (newValue.length) setErrorTooltip(false); //close the tooltip if there is at least 1 valid search term
setValue(newValue);
onChange_internal(newValue);
onSelect_internal(newValue); // clicking enter to select a autocomplete suggestion triggers a new search (it also 'Enters' for the searchbar)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TyHil Is this fine. newValue is a parameter for this function (it is an array with previous and the new SearchQueries). I am passing it in directly to onSelect_internal() instead of passing in value.

setValue sets value = newValue

I wanted to pass in value, but that does not get updated in time ig for onSelect_internal; newValue works fine and value eventually does get updated.


The other thing is there is a function handleKeyDown() that calls onSelect_internal when the enter key is pressed after adding all search terms (like I added cs1200 by clicking on it or SPACE or smtg, now I click enter).

Is it fine to have onSelect_internal to be called twice like this? Feels icky to mee

Copy link
Member

Choose a reason for hiding this comment

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

newValue is perfect

I suppose if we can remove handleKeyDown and the code still works then that would be good

src/components/common/SearchBar/searchBar.tsx Show resolved Hide resolved
src/pages/dashboard/index.tsx Outdated Show resolved Hide resolved
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

@AbhiramTadepalli
Copy link
Contributor Author

AbhiramTadepalli commented Nov 8, 2024

What do you think of the commit I made to do the page title without an extra state?

Nice!

intentional choice to capitalize UTD TRENDS?

yes, but what do you think?


11e2a2f the link preview says "Results - UTD Trends" and skips over pageTitle

This reverts commit 673bbf4.
@AbhiramTadepalli
Copy link
Contributor Author

AbhiramTadepalli commented Nov 8, 2024

@TyHil pageTitle for the meta tag is not dynamically updating it sets it as whatever pageTitle was when initialized first (pageTitle = '' or pageTitle = 'test' in commit 9dc3e06)

@TyHil
Copy link
Member

TyHil commented Nov 8, 2024

@TyHil pageTitle for the meta tag is not dynamically updating it sets it as whatever pageTitle was when initialized first (pageTitle = '' or pageTitle = 'test' in commit 9dc3e06)

yeah i don't think it can be dynamic

re: capitalization

seems good, just needs to be changed in _app and _document to match

will look at questions soon

Copy link
Member

@TyHil TyHil left a comment

Choose a reason for hiding this comment

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

  • Address inline code comments
  • Make og:title tag not dynamic
  • Standardize capitalization

@AbhiramTadepalli
Copy link
Contributor Author

  • When I use ENTER to select and search a searchterm, it takes a minute for the results to start loading
    • why
    • Can we get the loading animation earlier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants