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(404): add button for searches #869

Merged
merged 11 commits into from
Nov 18, 2024
Merged

fix(404): add button for searches #869

merged 11 commits into from
Nov 18, 2024

Conversation

seaerchin
Copy link
Contributor

Problem

on the 404 page, users are not able to take action to self-resolve the issue

Solution

  1. add a button (for now) that redirects to the searchsg page so that users can self-resolve the issue

1. duplicate infobar to not found layout
2. export styles from infobar so it's kept in sync
3. add client component for search button
@seaerchin seaerchin requested a review from a team as a code owner November 11, 2024 10:23
Copy link

vercel bot commented Nov 11, 2024

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

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 16, 2024 5:55am

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 11, 2024

Datadog Report

Branch report: fix/404
Commit report: a604257
Test service: isomer-studio

✅ 0 Failed, 188 Passed, 34 Skipped, 35.78s Total Time
⬆️ Test Sessions change in coverage: 1 increased (+1.65%)

const [permalink, setPermalink] = useState("")

useLayoutEffect(() => {
// The check for typeof window and navigator ensures this only runs in browser environments, not during server-side rendering
Copy link
Contributor

Choose a reason for hiding this comment

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

this will never be server-side rendered due to "use client" declarative at top

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not server-side rendered but nextjs will transpile then serve the js at runtime. this led to compile errors as window is undefined when transpiling

@@ -0,0 +1,15 @@
export const getWordsFromPermalink = (permalink: string): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

checking understanding:

so https://example.com/some-page_name+ will yield some+page+name right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap excatly

Copy link
Contributor

@adriangohjw adriangohjw left a comment

Choose a reason for hiding this comment

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

When deploying to a test site, im unsure why does the URL render an incorrect link /search/?q=... instead of /search?q=... when the react props is correct, will look into it

Screenshot 2024-11-16 at 1 33 57 PM

@dcshzj
Copy link
Contributor

dcshzj commented Nov 16, 2024

When deploying to a test site, im unsure why does the URL render an incorrect link /search/?q=... instead of /search?q=... when the react props is correct, will look into it

We know that this comes from the trailingSlash config inside next.config.js. The CloudFront redirect function will need to be updated to handle this.

Copy link
Contributor

@adriangohjw adriangohjw left a comment

Choose a reason for hiding this comment

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

after digging more into nextjs, it seems like entering /search/?q=abc doesn't work (incorrectly redirected by our CF to /search) but clicking on the button rendered by nextjs does not go through our CF redirect so this still works.

i think we don't have to update our CF since we don't have to support people typing /search/?q=abc for now

nevertheless, have logged them into https://linear.app/ogp/issue/ISOM-1680/aws-cloudfront-function-does-not-handle-edge-case for future work

@dcshzj dcshzj merged commit acfed65 into main Nov 18, 2024
31 checks passed
@dcshzj dcshzj deleted the fix/404 branch November 18, 2024 06:06
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.

4 participants