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: set filter correctly when navigating back from details page #263

Merged
merged 8 commits into from
Mar 19, 2024

Conversation

jonasbrunvoll
Copy link
Contributor

Closes https://github.com/AtB-AS/kundevendt/issues/17194

Background

When going into a details page and navigating back the filter for transport mode is not included in the query, causing the filter to be reset to default.

Illustrations

The recording displays how the same filters are active before and after navigating to the details page. This can be seen in both the filter buttons and URL parameters.

screenshots/video/figma
Skjermopptak.2024-03-14.kl.12.15.33.mov

Proposed solution

Including a string made up by the selected transport mode filters to generate the singleTripQueryString. Thus, the same string is available when the singleTripQueryString is decompressed, making it possible to set the parameters again when navigating back from details page.

Acceptance Criteria

  • The set transport mode filter remains the same when going to details page and navigating back.
  • Going to details page from copied url and navigating back keeps the transport mode filter.

…generate the singleTripQueryString. Thus, the same string is available when the singleTripQueryString is decompressed, making it possible to set the parameters again when navigating back from details page.
Copy link

vercel bot commented Mar 14, 2024

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

Name Status Preview Comments Updated (UTC)
planner-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 19, 2024 3:24pm

@github-actions github-actions bot added the C-bug label Mar 14, 2024
@mortennordseth
Copy link
Contributor

Notater fra felles gjennomgang av PR:

  • Legge til filter som query param i stedet for å utvide compressed query

@jonasbrunvoll
Copy link
Contributor Author

I was unable to navigate to the details page when / was used as a delimiter. I therefore chose to use ___ instead.

@mortennordseth
Copy link
Contributor

I was unable to navigate to the details page when / was used as a delimiter. I therefore chose to use ___ instead.

I think you should use query string instead (https://en.wikipedia.org/wiki/Query_string). For example ?filter=bus or ?filter=bus,rail. This is in line with what is done for the /assistant page as well

Comment on lines 30 to 32
const tripSearchParams = router.query.id
? tripQueryStringToQueryParams(String(router.query.id))
? tripQueryStringToQueryParams(router.query)
: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

You might disagree with me, but I don't think we should modify tripQueryStringToQueryParams without changing the decompressedQueryString. What about doing something like this?

  const tripSearchParams = router.query.id
    ? tripQueryStringToQueryParams(String(router.query.id))
    : undefined;

  if (tripSearchParams && router.query.filter) {
    tripSearchParams.append('filter', router.query.filter as string);
  }

This only requires us to add the filter as a query param to the href in /trip-pattern/index.tsx (already done) and to use it when redirecting back to the travel suggestions (the suggested code above)

Copy link
Contributor

@mortennordseth mortennordseth left a comment

Choose a reason for hiding this comment

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

Nice

@jonasbrunvoll jonasbrunvoll merged commit 0852ee5 into main Mar 19, 2024
6 checks passed
@jonasbrunvoll jonasbrunvoll deleted the jonas/set_filters_from_details_page branch March 19, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants