-
Notifications
You must be signed in to change notification settings - Fork 334
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
Components failing initialisation break due to .js-enabled
styles
#999
Comments
Potentially by solving #1127 we could then use that to solve this issue. Since they both rely on knowing of instances of GOV.UK Frontend components on the page. We could then say if no instances were set, then assume something blew up. |
We had a similar issue in my service this week. For reasons our service's js file for IE failed to compile so our service's js wasn't available in IE - but we still had the If there are recommended solutions - like testing for a variable I'd be keen to hear them. |
Hello all, Currently experiencing this issue- what was the fix for this? Thanks
E |
When www.gov.uk was down today and I wanted to send someone a link to it via the Wayback Machine, I found that I couldn't get to any of the main links within an accordion because the JavaScript wasn't archived. Although the page in question was not using the accordion from the Design System, I checked that the effect on the Design System accordion would be the same. So, here is that real world example: http://web.archive.org/web/20210205010100/https://www.gov.uk/service-manual/helping-people-to-use-your-service Usually, when you click on "Meeting accessibility requirements", the section underneath would open and reveal a couple of links. This is worse than Nick's original example because it's impossible to get to the links and you cannot even see that anything is missing. |
useEffect(() => { Place this code into your root component, this fix works for me!!
|
.js-enabled
styling
.js-enabled
styling.js-enabled
styles
Adding a list of scenarios from: For context: We improved Accordion sections to be visible during page load in #3053 but for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation We'd like to review similar components load with:
(Where "skipped checks" could be an early |
When loading the Accordion component with JavaScript enabled, this change restores `display: none` on section content For context, we switched to `display: inherit` previously: #3053 But for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation We’d like to take another look at how components load in: #999
When loading the Accordion component with JavaScript enabled, this change restores `display: none` on section content For context, we switched to `display: inherit` previously: #3053 But for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation We’d like to take another look at how components load in: #999
When loading the Accordion component with JavaScript enabled, this change restores `display: none` on section content For context, we switched to `display: inherit` previously: #3053 But for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation We’d like to take another look at how components load in: #999
When loading the Accordion component with JavaScript enabled, this change restores `display: none` on section content For context, we switched to `display: inherit` previously: #3053 But for slow-loading pages we saw a visual layout shift as each section flickered closed (from open) after initialisation We’d like to take another look at how components load in: #999
An example of this came up last Friday in an incident on GOV.UK. A change was rolled out which introduced an error in their analytics JavaScript, which caused the JS for other components to fail. From their incident doc (internal, only visible to folks from GDS):
Off the back of this, GOV.UK have wrapped the initialisation of each component in a try / catch block to try and limit the impact of errors in any individual JavaScript module. Although we now have a recent example of why this is a problem, it's still come up (surprisingly) rarely since this issue was raised, so at the minute this isn't going to be prioritised over the work planned for the next quarter, but we hope to look at this soon. |
Before they get lost, a scrappy attempt to capture potential ideas to explore from various people on Slack, in no particular order:
|
On GOV.UK we've just implemented wrapping each module initialisation in a try/catch block. It should stop one module from taking down the whole page, but won't solve the accordion problem if it's the accordion that fails to initialise properly. |
The |
It is possible for components to be in a completely broken state if the user has JavaScript enabled but the GOV.UK Frontend bundle fails to download.
Previously we detected the presence of
GOV.UK
globally on window, but we removed this since we could not be sure if people would be using bundlers which will not output a global.https://github.com/alphagov/govuk_template/blob/master/source/views/layouts/govuk_template.html.erb#L113
We could consider, injecting a global whenever a component is loaded that can remove js-enabled.
Potentially something like:
https://trello.com/c/oRDkiAz9/1448-frontend-components-appeared-styled-when-js-blocked
The text was updated successfully, but these errors were encountered: