-
Notifications
You must be signed in to change notification settings - Fork 114
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
TCCP: Add breadcrumbs to card detail page #8263
Conversation
Putting a hold on this one. It sounds like @contolini has a better way to handle breadcrumbs with HTMX, so this workaround my not be needed at all. |
Great point. Due to the small size of the app, I think I'd prefer to keep everything in one file and add scoping logic that's specific to the functionality (instead of adding logic like "if on page X do Y"). So the function updateBreadcrumb() {
const crumb = document.querySelector('.m-breadcrumbs_crumb:last-child');
if (crumb.innerText === 'Customize for your situation') {
crumb.href = webStorageProxy.getItem('tccp-filter-path') || crumb.href;
}
}
I say we lean on cypress tests for now (I added some in #8266) because so far all our JS is heavily tied to the DOM. |
a4c8576
to
5e66afa
Compare
5e66afa
to
aa3c34a
Compare
aa3c34a
to
7cdccef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Once we add dummy data we can write tests for the breadcrumb.
@contolini, you beat me to it—I was going to add some simple breadcrumb tests and |
Adds breadcrumbs to the card details page and progressively enhances them with JavaScript so the breadcrumb that points back to the card list will take you to the specific filtered list you came from.
We have to update that breadcrumb client-side because there's a chance Akamai may cache a version of the page with a breadcrumb to a specific filtered list if we do it on the backend, see #7108 for details. I'm comfortable making this enhancement here even though we chose to remove it in other places. A primary goal of the TCCP tool is to help users compare different cards that meet their needs, so we're actually hoping they'll go from a filtered list to card details back to the filtered list and so on to look at a number of different cards. Most people will use the back button for that, but for those who don't, we want to make sure they can always get back to the filtered list they came from.
@chosak and @contolini, a couple of specific questions I had with this one:
init()
so each page only runs the relevant stuff? ThepreviousPage.pathname.includes(cardListPagePath)
condition inupdateBreadcrumb()
should prevent the breadcrumb update from happening on the card list page, but is that better done elsewhere?previousPage.hostname === window.location.hostname
condition assuage our concerns about only updating the breadcrumb if you're coming from a cf.gov page?And more generally, any other approaches to this that would make more sense?
Additions
How to test this PR
Screenshots
Notes and todos
replaceState
when you change the filters on the card list page, so technically this breadcrumb isn't fully working yet. It will always take you back to the filtered list you first landed on from the landing page, even if you then change the filters on the list page. @contolini is working on a fix to enablereplaceState
to work with Akamai caching. When that's done we'll check the breadcrumbs to make sure they're working as expected (and remove the TODO note).Checklist