Add guard to accordion component init method #4069
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
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
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.