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 GOV.UK Chat promo on pages with multiple path segments #3440

Merged
merged 1 commit into from
Nov 26, 2024

Conversation

jackbot
Copy link
Contributor

@jackbot jackbot commented Nov 26, 2024

We have an allow list of URLs on which we want to render the GOV.UK Chat
promo, which we compare the content item's base_path against to
determine whether to show the promo or not.

This results in a bug in some guide pages where we only want to show the
promo on certain steps of the guide.

Let's consider the "/contracted-out" URL. This guide has 3 steps, and so
3 URLs

  1. /contracted-out
  2. /contracted-out/how-contracting-out-affects-your-amount
  3. /contracted-out/check-if-you-were-contracted-out

We only want to show the promo on URL 1 and 3 in the list above, but not
the second one.

With the current logic, we're showing the promo on all of these URLs.
That's because we're looking at the content_item.base_path property,
which is "/contracted-out" for all of those URLs.

Instead we should do the comparison on the requested_path method,
which is the full path.

It also fixes a bug in a similar vein where we want to show the promo on
only one of the sub-pages in a guide (e.g. URL 2 above), but because
we're comparing against the base_path, we end up showing it on all
pages of the guide.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3440 November 26, 2024 09:29 Inactive
We have an allow list of URLs on which we want to render the GOV.UK Chat
promo, which we compare the content item's `base_path` against to
determine whether to show the promo or not.

This results in a bug in some guide pages where we only want to show the
promo on certain steps of the guide.

Let's consider the "/contracted-out" URL. This guide has 3 steps, and so
3 URLs

1. /contracted-out
2. /contracted-out/how-contracting-out-affects-your-amount
3. /contracted-out/check-if-you-were-contracted-out

We only want to show the promo on URL 1 and 3 in the list above, but not
the second one.

With the current logic, we're showing the promo on all of these URLs.
That's because we're looking at the `content_item.base_path` property,
which is "/contracted-out" for all of those URLs.

Instead we should do the comparison on the `requested_path` method,
which is the full path.

It also fixes a bug in a similar vein where we want to show the promo on
only one of the sub-pages in a guide (e.g. URL 2 above), but because
we're comparing against the `base_path`, we end up showing it on all
pages of the guide.
@jackbot jackbot force-pushed the fix-govuk-chat-promo-link branch from 95e39a2 to 0b829ce Compare November 26, 2024 09:31
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3440 November 26, 2024 09:31 Inactive
Copy link
Contributor

@davidgisbey davidgisbey left a comment

Choose a reason for hiding this comment

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

nice catch. Makes sense to me 👍

@jackbot jackbot merged commit 7407b35 into main Nov 26, 2024
11 checks passed
@jackbot jackbot deleted the fix-govuk-chat-promo-link branch November 26, 2024 09:39
kevindew added a commit that referenced this pull request Dec 3, 2024
In #3440 we changed
the mechanism for rendering the GOV.UK Chat banner to utilise request
path rather than content item base_path. A side effect of this was that
for any existing guides that we were embedding the banner on lost the
banner on any of their nested sections.

This commit adds each individual path of guides that previously had the
banner.
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.

3 participants