-
Notifications
You must be signed in to change notification settings - Fork 20
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
Data attributes for option select button #3750
Conversation
- allow it to accept data attributes to be applied to the expand/collapse button - will allow us to add GA4 tracking via a Rails/component approach and remove some JS - likely to be a breaking change as will depend on some other stuff in a subsequent commit - brings the component more in line with the option select component changes coming here: alphagov/govuk_publishing_components#3750
1533a8a
to
a223f99
Compare
a223f99
to
8b8bb51
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.
Looks good 👍
Do you think it's worth having a try/catch
safeguard on the JavaScript in case the value doesn't come through as a JSON? E.g. passing button_data_attributes: "hello"
crashes the JS. This is probably an incredibly rare scenario so don't worry about it if you think it's over engineering the code.
@AshGDS good shout, we do that everywhere else so we should do it here. Have pushed another commit if you've got time to take a look, will squash before merging. |
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, thanks @andysellick 👍
Whoops, didn't mean to approve if further changes are coming
ec99028
to
4d008d9
Compare
@AshGDS I'm not intending adding further changes to this PR, so you can approve if you're happy. I'll roll this out as a breaking release and get it into alphagov/finder-frontend#3224 |
3d04ecd
to
0ffde2c
Compare
- modify the option select component to allow it to accept data attributes to be added to the expand/collapse button - the attributes are rendered on the parent element, then read in by JavaScript to be included in the JavaScript generated button, which replaces the title element of the component - to be used for GA4 tracking purposes in finder-frontend, in place of an existing solution - will be a breaking change, as removes the event listener that was previously being used for this - credit to @floehopper
0ffde2c
to
114d9ed
Compare
- allow it to accept data attributes to be applied to the expand/collapse button - will allow us to add GA4 tracking via a Rails/component approach and remove some JS - likely to be a breaking change as will depend on some other stuff in a subsequent commit - brings the component more in line with the option select component changes coming here: alphagov/govuk_publishing_components#3750
- allow it to accept data attributes to be applied to the expand/collapse button - will allow us to add GA4 tracking via a Rails/component approach and remove some JS - likely to be a breaking change as will depend on some other stuff in a subsequent commit - brings the component more in line with the option select component changes coming here: alphagov/govuk_publishing_components#3750
What
Why
We're currently using a system of event and event listeners between
finder-frontend
and this component in order to track this button's expand/collapse action. This approach allows us to remove some JavaScript and move most of the heavy lifting to the backend, which should reduce load on the frontend.This PR in
finder-frontend
is dependent on this change, and will need to be merged together: alphagov/finder-frontend#3224Visual Changes
None.
Trello card: https://trello.com/c/OdYXlYqQ/673-finder-frontend-code-optimisations