diff --git a/app/components/Button.tsx b/app/components/Button.tsx index 87a11b59c..41193ea23 100644 --- a/app/components/Button.tsx +++ b/app/components/Button.tsx @@ -51,9 +51,25 @@ function Button({ const textSpan = text ? {text} : ""; const childrenSpan = {children}; + // for links that have role="button" we need to add an event handler so that it can + // be activated with the space bar + // see: https://github.com/alphagov/govuk_elements/pull/272#issuecomment-233028270 + const onKeyDown = (event: React.KeyboardEvent) => { + if (event.code === "Space") { + event.currentTarget.click(); + event.preventDefault(); + } + }; + if (href) { return ( - + {iconLeft} {children ? childrenSpan : textSpan} {iconRight} );