Skip to content

Conversation

@kr8n3r
Copy link
Contributor

@kr8n3r kr8n3r commented Nov 27, 2025

What

We want to migrate all of our legacy Javascript files to ESM, so this is the latest in the series of conversions.

Trello ticket

Rewrite follows the same conventions we previously used for RadioSelect, FocusBanner, Collapsible checkboxes, ColourPreview, FileUpload, Autofocus, PreviewPane, CopyToClipboard and others.

In this PR we:

  • rewrite the module as ES Module
  • update the tests to be ES Module
  • use it authenticateSecurityKeys and registerSecurityKeys modules and tests
  • remove old module JS file
  • remove old module from the legacy bundle build
  • fix to rollup.config from Rewrite UpdateStatus as an ES Module #5366 where legacy files weren't quite removed

Review

  • see individual commits
  • run locally and test: used on the login and /your-account pages when authenticating and adding new security keys

@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch 4 times, most recently from 20913fd to 01ecc1c Compare November 27, 2025 15:29
@kr8n3r kr8n3r marked this pull request as ready for review November 27, 2025 15:36
@tombye tombye self-assigned this Nov 27, 2025
@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch 2 times, most recently from f0c2a15 to 80caf98 Compare November 28, 2025 10:14
Instead of using 'govuk-!-display-none' class
to hide the banner, we'll use the hidden attribute
so that we don't rely on CSS to hide it.

We're adding a 'webauthn__error' class to the
banner that's used in ErrorBanner JS so we can
target it directly instead of toggling all 3.

The other two banners are for no-js and no-webauthn
support.
@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch from 80caf98 to dd421f8 Compare November 28, 2025 10:19
This PR rewrites the code into ES Module format
that we've been using.

Pages where this is used contain 3 error banners:
no-js, no webauth-api and error when autheticating/
registering.

We're using 'hidden' attribute instead of
a CSS class to hide/show banner.

Module accepts a custom selector, which we use
in authenticateSecurityKey and registerSecurityKey
modules.
Move to .mjs and use new ErrorBanner module.
Added additonal tests to check module works
when custom css selector is passed to
the constructor.
Replace window.GOV.UK.ErrorBanner with the new ES
Module.
As the error banner is hidden there is no need to
hide it on load again.
Replace window.GOV.UK.ErrorBanner with the new ES
Module. As the error banner is hidden there is no need to
hide it on load again.
@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch from dd421f8 to 5aed708 Compare November 28, 2025 10:26
@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch 2 times, most recently from 1cd8f14 to 6a95edf Compare November 28, 2025 11:36
Use the new ErrorBanner module and test that
its correct methods are being called.
Use the new ErrorBanner module and test that
its correct methods are being called.
Remove file and remove from build bundle
@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch from 6a95edf to 7854326 Compare November 28, 2025 14:54
@kr8n3r kr8n3r force-pushed the rewrite-error-banner-as-esm branch from 9a199cf to d11f0df Compare November 28, 2025 19:00
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