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 guard to accordion component init method #4069

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

MartinJJones
Copy link
Contributor

@MartinJJones MartinJJones commented Jun 20, 2024

What

  • Add guard to accordion component init method
  • Add new test and update fixture

Why

When the accordion component from govuk-frontend is initialised, the govuk-accordion__show-all class is added to the button element.

It is possible that the accordion component from govuk-frontend does not get initialised, but we have no checks in place to guard against this when initialising the accordion component from the gem.

Example error when using the accordion component with V5 govuk-frontend in Safari 10.1
Screenshot 2024-06-20 at 13 57 38

This change checks if the accordion component from govuk-frontend has initialised before trying to initialise the accordion component from the publishing components gem.

A new test has been added to check it does not initialise, if the accordion from govuk-frontend has not initialised. gem-c-accordion__show-all was removed from the fixture as this is added by the JS from the publishing-components accordion.

@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4069 June 20, 2024 12:51 Inactive
@MartinJJones MartinJJones force-pushed the update-accordion-initialisation-check branch from 04eed7c to 93b58c5 Compare June 20, 2024 12:52
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4069 June 20, 2024 12:53 Inactive
When the accordion component from govuk-frontend is initialised, the `govuk-accordion__show-all` class is added to the button element.

It is possible that the accordion component from govuk-frontend does not get initialised, but we have no checks in place to guard against this when initialising the accordion component from the gem.

This change checks if the accordion component from govuk-frontend has initialised before trying to initialise the accordion component from the publishing components gem.

A new test has been added to check it does not initialise, if the accordion from govuk-frontend has not initialised. `gem-c-accordion__show-all` was removed from the fixture as this is added by the JS from the publishing-components accordion.
@MartinJJones MartinJJones force-pushed the update-accordion-initialisation-check branch from 93b58c5 to 859c06c Compare June 20, 2024 12:55
@govuk-ci govuk-ci temporarily deployed to components-gem-pr-4069 June 20, 2024 12:55 Inactive
@MartinJJones MartinJJones marked this pull request as ready for review June 20, 2024 12:59
Copy link
Contributor

@andysellick andysellick left a comment

Choose a reason for hiding this comment

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

👍

@MartinJJones MartinJJones merged commit 33ff5e3 into main Jun 20, 2024
11 checks passed
@MartinJJones MartinJJones deleted the update-accordion-initialisation-check branch June 20, 2024 14:19
@MartinJJones MartinJJones mentioned this pull request Jun 26, 2024
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