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

Merged
merged 29 commits into from
Nov 21, 2024

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 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 21, 2024 0:57am

@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?

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

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

… pageTitle. The useState hook updates when router.query.searchTerms changes, and since the <title> relies on dynamicPageTitle, it gets updated automatically.
…ofessor). Also fix improper slicing in link preview
…in getServerSideProps and in a Dashboard useEffect for router.query.searchTerms
…unction dynamically for <title>; use SSR-generated pageTitle for the og:title meta tag
@AbhiramTadepalli
Copy link
Contributor Author

AbhiramTadepalli commented Nov 20, 2024

alright alright alright.

This PR does:
(1) Dynamic Page titles
(2) More intuitive browser navigation: every new search triggers an entry on the history stack
(3) Clicking enter once selects the topmost autocomplete suggestion AND searches

(4) Dynamic Link Previews:

  • getServerSideProps does server-side-rendering (SSR) to build a page title from the search terms. This is passed into Dashboard as the string pageTitle which is assigned to the og:title meta property.
  • The page title (what goes in the browser tab and in the browser history stack) is dynamically generated (state-less).
  • When router.query.searchTerms changes (search terms change), the new function getSearchTerms(searchTermInput: string | string[] | undefined): { courseSearchTerms: SearchQuery[]; professorSearchTerms: SearchQuery[]; } separates the search terms into courseSearchTerms and professorSearchTerms of type SearchQuery[]
  • The new function buildPageTitle( courseSearchTerms: SearchQuery[], professorSearchTerms: SearchQuery[], ): string generates a the page's title by concatenating courses then professors separated by a comma. The string ends with a " - " so that it can be easily used without ternaries in the html:
        <title>
          {'Results - ' + buildPageTitle(courses, professors) + 'UTD TRENDS'}
        </title>
        <link
          rel="canonical"
          href="https://trends.utdnebula.com/dashboard"
          key="canonical"
        />
        <meta
          key="og:title"
          property="og:title"
          content={'Results - ' + pageTitle + 'UTD TRENDS'}
        />
        <meta
          property="og:url"
          content="https://trends.utdnebula.com/dashboard"
        />```

@AbhiramTadepalli
Copy link
Contributor Author

AbhiramTadepalli commented Nov 20, 2024

2 things to note re: [Feature Request] Search Engine Optimization (SEO)

  1. We want dashboard links to be in Google Search (links with searchterms
  2. SSR unlocks dynamic meta tags for search engine crawlers

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.

Great!

@TyHil TyHil merged commit 775c602 into develop Nov 21, 2024
3 checks passed
@TyHil TyHil deleted the fix-browser-nav branch November 21, 2024 16:21
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