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

Add javascript for domain/subdomain widget behaviour #89

Merged
merged 4 commits into from
Feb 26, 2024

Conversation

MatMoore
Copy link
Contributor

@MatMoore MatMoore commented Feb 20, 2024

Issue: #87

This is based on a similar topic/subtopic widget from GOV.UK: https://github.com/alphagov/finder-frontend/blob/ebee8ca91224eea3876490da1775aa568690f94a/app/assets/javascripts/taxonomy-select.js

This PR adds the javascript to support this widget, but does not yet wire it up to django. I will do this once @mitchdawson1982's changes are merged.

This is what it looks like with example HTML:

domain-widget.mov

Progressive enhancement

This component uses progressive enhancement so that we gracefully fallback to the basic top-level domain select if the javascript fails to load for any reason.

Testing

I've introduced jest as a javascript testing framework and integrated that with the CI. You can run it with npm test.

Possible extensions

We may want to add functionality later to make other parts of the page (such as the list of selected filters) live refresh when the domain/subdomain changes.

I've not implemented this now, because we already have an "Apply filters" button and I didn't want to diverge too much from the MOJ filter component before we've put this in front of users. But I've implemented a custom event so the state of this component is observable.

@MatMoore MatMoore force-pushed the subdomain-filter branch 6 times, most recently from b05e527 to 0e7fdf7 Compare February 22, 2024 12:53
@MatMoore MatMoore changed the title WIP - start javascript for domain filter widget WIP - Add javascript for domain/subdomain widget behaviour Feb 22, 2024
Domain will have top level and subdomain selections, and work similarly
to "Topic/Sub-Topic" on GOV.UK search.

The form will submit domain and subdomain as separate fields, so we
need to combine them on the backend.

If javascript is not enabled, then the subdomain field is not displayed
and it will work as before.

This is tested using jest and jest-dom.
@MatMoore MatMoore changed the title WIP - Add javascript for domain/subdomain widget behaviour Add javascript for domain/subdomain widget behaviour Feb 22, 2024
@MatMoore MatMoore marked this pull request as ready for review February 22, 2024 13:06
@MatMoore MatMoore force-pushed the subdomain-filter branch 3 times, most recently from 20821f1 to 4c5778f Compare February 26, 2024 10:15
tom-webber
tom-webber previously approved these changes Feb 26, 2024
Copy link
Contributor

@tom-webber tom-webber left a comment

Choose a reason for hiding this comment

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

Looks great!

The chromedriver library updates more frequently than the chrome
distributed in ubuntu-latest, but these need to be the same version,
otherwise axe-core breaks.

As a workaround, try to install a version that matches whatever chrome
is on the path.

See also dequelabs/axe-core-npm#401 (comment)
@MatMoore MatMoore merged commit 8344582 into main Feb 26, 2024
3 checks passed
@MatMoore MatMoore deleted the subdomain-filter branch February 26, 2024 11:41
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