From 04b0c4f013c7eae6dd56da5efb9459e37aff59fa Mon Sep 17 00:00:00 2001 From: cocomarine Date: Thu, 19 Nov 2026 17:01:44 +0000 Subject: [PATCH 1/8] turn ErrorMessage into disclosure element --- public/translations/en.json | 3 ++ src/assets/icons/chevron_down.svg | 8 +-- src/assets/stylesheets/ErrorMessage.scss | 49 ++++++++++++++++++- .../Editor/ErrorMessage/ErrorMessage.jsx | 35 ++++++++----- .../Editor/ErrorMessage/ErrorMessage.test.jsx | 19 ++++++- 5 files changed, 96 insertions(+), 18 deletions(-) diff --git a/public/translations/en.json b/public/translations/en.json index 9ee80fc55..c14eafb6b 100644 --- a/public/translations/en.json +++ b/public/translations/en.json @@ -215,6 +215,9 @@ "errors": { "interrupted": "Execution interrupted" }, + "errorMessage": { + "title": "Error running your code" + }, "aiErrorMessages": { "loadingText": "Generating hint", "buttonText": "Need help? Generate an AI hint", diff --git a/src/assets/icons/chevron_down.svg b/src/assets/icons/chevron_down.svg index 77708f4a0..c4da7a249 100644 --- a/src/assets/icons/chevron_down.svg +++ b/src/assets/icons/chevron_down.svg @@ -1,9 +1,9 @@ - + diff --git a/src/assets/stylesheets/ErrorMessage.scss b/src/assets/stylesheets/ErrorMessage.scss index 409b7b947..ae2f90a49 100644 --- a/src/assets/stylesheets/ErrorMessage.scss +++ b/src/assets/stylesheets/ErrorMessage.scss @@ -5,15 +5,60 @@ color: var(--rpf-red-900); background-color: var(--rpf-red-100); border-block: 1px solid var(--editor-color-outline); - padding: var(--space-1); overflow-y: auto; + &__summary { + display: flex; + align-items: center; + justify-content: space-between; + gap: var(--space-1); + padding: var(--space-1); + list-style: none; + cursor: pointer; + + &::-webkit-details-marker { + display: none; + } + } + + details[open] &__summary { + border-block: 1px solid var(--rpf-red-200); + } + + &__title { + display: flex; + align-items: center; + gap: var(--space-1); + margin: 0; + @include typography.style-1; + font-weight: bold; + + svg { + flex-shrink: 0; + } + } + + &__chevron { + flex-shrink: 0; + fill: var(--rpf-text-primary); + transition: transform 0.2s ease-in-out; + } + + details[open] &__chevron { + transform: rotate(180deg); + } + + &__content { + padding-block: var(--space-1); + padding-inline: var(--space-1-5); + } + &__error { padding: 0; margin: 0; + font-family: inherit; white-space: pre-wrap; overflow-wrap: break-word; - font-weight: bold; } &__python { diff --git a/src/components/Editor/ErrorMessage/ErrorMessage.jsx b/src/components/Editor/ErrorMessage/ErrorMessage.jsx index 419fcc724..666897472 100644 --- a/src/components/Editor/ErrorMessage/ErrorMessage.jsx +++ b/src/components/Editor/ErrorMessage/ErrorMessage.jsx @@ -2,8 +2,10 @@ import React, { useContext } from "react"; import "../../../assets/stylesheets/ErrorMessage.scss?inline"; import { useSelector } from "react-redux"; import DOMPurify from "dompurify"; +import { useTranslation } from "react-i18next"; import { SettingsContext } from "../../../utils/settings"; import CancelFillIcon from "../../../assets/icons/cancel_FILL.svg"; +import ChevronDownIcon from "../../../assets/icons/chevron_down.svg"; import FriendlyErrorMessage from "../FriendlyErrorMessage/FriendlyErrorMessage"; import AiErrorMessage from "../AiErrorMessage/AiErrorMessage"; import useAiHintOffered from "../../../hooks/useAiHintOffered"; @@ -11,21 +13,32 @@ import useAiHintOffered from "../../../hooks/useAiHintOffered"; const ErrorMessage = () => { const error = useSelector((state) => state.editor.error); const settings = useContext(SettingsContext); + const { t } = useTranslation(); const aiHintOffered = useAiHintOffered(); return error ? (
-
- -
-      
- - {aiHintOffered && } +
+ + + + {t("output.errorMessage.title")} + + + +
+
+
+          
+ + {aiHintOffered && } +
+
) : null; }; diff --git a/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx b/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx index 2c5225b04..df20f663d 100644 --- a/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx +++ b/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx @@ -2,7 +2,7 @@ import configureStore from "redux-mock-store"; import { Provider } from "react-redux"; import { SettingsContext } from "../../../utils/settings"; import ErrorMessage from "./ErrorMessage"; -import { render, screen } from "@testing-library/react"; +import { fireEvent, render, screen } from "@testing-library/react"; import useIsOnline from "../../../hooks/useIsOnline"; import { Cookies, CookiesProvider } from "react-cookie"; @@ -45,6 +45,23 @@ describe("When error is set", () => { expect(screen.queryByText("Oops")).toBeInTheDocument(); }); + test("Displays the error title in an expanded details section", () => { + const title = screen.getByText("output.errorMessage.title"); + expect(title.closest("summary")).toBeInTheDocument(); + expect(title.closest("details")).toHaveAttribute("open"); + }); + + test("Clicking the title collapses and expands the error details", () => { + const title = screen.getByText("output.errorMessage.title"); + const details = title.closest("details"); + + fireEvent.click(title); + expect(details).not.toHaveAttribute("open"); + + fireEvent.click(title); + expect(details).toHaveAttribute("open"); + }); + test("Font size class is set correctly", () => { const errorMessage = screen.queryByText("Oops").parentElement; expect(errorMessage).toHaveClass("error-message__python--myFontSize"); From 9b1f922cd62ddbafe18daef56cd3db0db82fdaca Mon Sep 17 00:00:00 2001 From: cocomarine Date: Thu, 19 Nov 2026 17:05:47 +0000 Subject: [PATCH 2/8] remove font resizing from python error --- src/assets/stylesheets/ErrorMessage.scss | 10 +--------- src/components/Editor/ErrorMessage/ErrorMessage.jsx | 7 +------ .../Editor/ErrorMessage/ErrorMessage.test.jsx | 5 ----- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/assets/stylesheets/ErrorMessage.scss b/src/assets/stylesheets/ErrorMessage.scss index ae2f90a49..dabdf1bb0 100644 --- a/src/assets/stylesheets/ErrorMessage.scss +++ b/src/assets/stylesheets/ErrorMessage.scss @@ -59,19 +59,11 @@ font-family: inherit; white-space: pre-wrap; overflow-wrap: break-word; + @include typography.style-1; } &__python { display: flex; gap: var(--space-1); - @include typography.style-1; - - &--medium { - @include typography.style-1; - } - - &--large { - @include typography.style-2; - } } } diff --git a/src/components/Editor/ErrorMessage/ErrorMessage.jsx b/src/components/Editor/ErrorMessage/ErrorMessage.jsx index 666897472..4950b59c6 100644 --- a/src/components/Editor/ErrorMessage/ErrorMessage.jsx +++ b/src/components/Editor/ErrorMessage/ErrorMessage.jsx @@ -1,9 +1,7 @@ -import React, { useContext } from "react"; import "../../../assets/stylesheets/ErrorMessage.scss?inline"; import { useSelector } from "react-redux"; import DOMPurify from "dompurify"; import { useTranslation } from "react-i18next"; -import { SettingsContext } from "../../../utils/settings"; import CancelFillIcon from "../../../assets/icons/cancel_FILL.svg"; import ChevronDownIcon from "../../../assets/icons/chevron_down.svg"; import FriendlyErrorMessage from "../FriendlyErrorMessage/FriendlyErrorMessage"; @@ -12,7 +10,6 @@ import useAiHintOffered from "../../../hooks/useAiHintOffered"; const ErrorMessage = () => { const error = useSelector((state) => state.editor.error); - const settings = useContext(SettingsContext); const { t } = useTranslation(); const aiHintOffered = useAiHintOffered(); @@ -27,9 +24,7 @@ const ErrorMessage = () => {
-
+
 {
       expect(details).toHaveAttribute("open");
     });
 
-    test("Font size class is set correctly", () => {
-      const errorMessage = screen.queryByText("Oops").parentElement;
-      expect(errorMessage).toHaveClass("error-message__python--myFontSize");
-    });
-
     test("Does not display friendly error elements", () => {
       expect(
         document.querySelector(".error-message__friendly"),

From e8501e52006ea63565011adaa3a8c9a2300239a1 Mon Sep 17 00:00:00 2001
From: cocomarine 
Date: Thu, 19 Nov 2026 17:26:06 +0000
Subject: [PATCH 3/8] update UX copies

---
 public/translations/en.json | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/public/translations/en.json b/public/translations/en.json
index c14eafb6b..aaebded83 100644
--- a/public/translations/en.json
+++ b/public/translations/en.json
@@ -220,9 +220,9 @@
     },
     "aiErrorMessages": {
       "loadingText": "Generating hint",
-      "buttonText": "Need help? Generate an AI hint",
+      "buttonText": "Generate an AI hint",
       "retryButtonText": "Try again",
-      "aiGeneratedHint": "AI generated hint",
+      "aiGeneratedHint": "AI-generated hint",
       "errorText": "We were not able to generate a hint, try again later.",
       "notice": "AI hints can be wrong. Learn more and share feedback",
       "turnOff": "Turn off AI hints"
@@ -363,7 +363,7 @@
     "charity": "Raspberry Pi Foundation - UK registered charity 1129409",
     "settingsMenu": {
       "heading": "Settings",
-      "aiHint": "AI generated hints",
+      "aiHint": "AI-generated hints",
       "aiHintDescription": "When your code has an error, you can generate a hint using AI. Hints do not give you the answer and can be wrong. Learn more about how AI hints work or share feedback.",
       "textSize": "Text size",
       "theme": "Theme",

From c258804aff88983f0d92fa07030b04291537465f Mon Sep 17 00:00:00 2001
From: cocomarine 
Date: Thu, 19 Nov 2026 17:36:12 +0000
Subject: [PATCH 4/8] update cencelFill icon and fix toggle link styling

---
 src/assets/icons/cancel_FILL.svg          | 6 +++---
 src/assets/stylesheets/SettingsPanel.scss | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/assets/icons/cancel_FILL.svg b/src/assets/icons/cancel_FILL.svg
index 5ef0d2fec..23f1bdc80 100644
--- a/src/assets/icons/cancel_FILL.svg
+++ b/src/assets/icons/cancel_FILL.svg
@@ -1,3 +1,3 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/src/assets/stylesheets/SettingsPanel.scss b/src/assets/stylesheets/SettingsPanel.scss
index f25d19873..c6e51e2e4 100644
--- a/src/assets/stylesheets/SettingsPanel.scss
+++ b/src/assets/stylesheets/SettingsPanel.scss
@@ -23,6 +23,10 @@
     p {
       color: var(--rpf-text-secondary);
       margin-block: var(--space-0-5) 0;
+
+      a {
+        font-weight: var(--font-weight-bold);
+		  }
     }
   }
 }

From 022bcf0b682c3aeefdc0aa119c9382397b91c7b0 Mon Sep 17 00:00:00 2001
From: cocomarine 
Date: Fri, 20 Nov 2026 10:24:38 +0000
Subject: [PATCH 5/8] add scrolling to error message content

---
 src/assets/stylesheets/ErrorMessage.scss | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/assets/stylesheets/ErrorMessage.scss b/src/assets/stylesheets/ErrorMessage.scss
index dabdf1bb0..1caf08e3b 100644
--- a/src/assets/stylesheets/ErrorMessage.scss
+++ b/src/assets/stylesheets/ErrorMessage.scss
@@ -5,7 +5,20 @@
   color: var(--rpf-red-900);
   background-color: var(--rpf-red-100);
   border-block: 1px solid var(--editor-color-outline);
-  overflow-y: auto;
+  display: flex;
+  flex-direction: column;
+  min-block-size: 0;
+
+  details {
+    display: flex;
+    flex-direction: column;
+    min-block-size: 0;
+
+    &::details-content {
+      min-block-size: 0;
+      overflow-y: auto;
+    }
+  }
 
   &__summary {
     display: flex;

From 14e7a738ab12771f54a8d26a78be6582d4804058 Mon Sep 17 00:00:00 2001
From: cocomarine 
Date: Fri, 20 Nov 2026 12:28:49 +0000
Subject: [PATCH 6/8] Improve screen reader support for error messages

Announce new errors politely without moving focus off the Run button, and move focus to the AI hint result so it isn't lost when the button that had focus is removed.
---
 .../Editor/AiErrorMessage/AiErrorMessage.jsx  | 16 ++++--
 .../AiErrorMessage/AiErrorMessage.test.jsx    | 24 ++++++++
 .../Editor/ErrorMessage/ErrorMessage.jsx      | 55 +++++++++++--------
 .../Editor/ErrorMessage/ErrorMessage.test.jsx | 24 +++++++-
 4 files changed, 91 insertions(+), 28 deletions(-)

diff --git a/src/components/Editor/AiErrorMessage/AiErrorMessage.jsx b/src/components/Editor/AiErrorMessage/AiErrorMessage.jsx
index e937fe259..97dbc35ed 100644
--- a/src/components/Editor/AiErrorMessage/AiErrorMessage.jsx
+++ b/src/components/Editor/AiErrorMessage/AiErrorMessage.jsx
@@ -46,6 +46,14 @@ const AiErrorMessage = () => {
     };
   }, [errorDetails]);
 
+  // Showing the hint removes the button that had focus, so move focus to the result.
+  const resultRef = useRef(null);
+  const showResult = Boolean(hint || failed);
+
+  useEffect(() => {
+    if (showResult) resultRef.current?.focus();
+  }, [showResult]);
+
   const handleButtonClick = async () => {
     const code =
       projectCode?.find((c) => c.name === "main" && c.extension === "py")
@@ -106,11 +114,11 @@ const AiErrorMessage = () => {
   };
 
   return (
-    
- {(hint || failed) && ( -
+
+ {showResult && ( +

- +

diff --git a/src/components/Editor/AiErrorMessage/AiErrorMessage.test.jsx b/src/components/Editor/AiErrorMessage/AiErrorMessage.test.jsx index 1d391698b..1f54f5f8f 100644 --- a/src/components/Editor/AiErrorMessage/AiErrorMessage.test.jsx +++ b/src/components/Editor/AiErrorMessage/AiErrorMessage.test.jsx @@ -140,6 +140,30 @@ describe("AiErrorMessage", () => { ).not.toBeInTheDocument(); }); + test("Moves focus to the hint when it replaces the button", async () => { + getAiErrorHint.mockResolvedValue({ data: { fem: "A friendly hint" } }); + renderAiErrorMessage(); + hintButton().focus(); + await clickButtonAndWait(); + + expect(document.querySelector(".ai-error-message__hint")).toHaveFocus(); + }); + + test("Moves focus to the error text when the request fails", async () => { + getAiErrorHint.mockRejectedValue(new Error("Bad gateway")); + renderAiErrorMessage(); + hintButton().focus(); + await clickButtonAndWait(); + + expect(document.querySelector(".ai-error-message__hint")).toHaveFocus(); + }); + + test("Does not move focus before a hint is requested", () => { + renderAiErrorMessage(); + + expect(document.body).toHaveFocus(); + }); + test("Keeps loading for the minimum time when the response is fast", async () => { getAiErrorHint.mockResolvedValue({ data: { fem: "A friendly hint" } }); renderAiErrorMessage(); diff --git a/src/components/Editor/ErrorMessage/ErrorMessage.jsx b/src/components/Editor/ErrorMessage/ErrorMessage.jsx index 4950b59c6..dee576386 100644 --- a/src/components/Editor/ErrorMessage/ErrorMessage.jsx +++ b/src/components/Editor/ErrorMessage/ErrorMessage.jsx @@ -13,29 +13,40 @@ const ErrorMessage = () => { const { t } = useTranslation(); const aiHintOffered = useAiHintOffered(); - return error ? ( -

-
- - - - {t("output.errorMessage.title")} - - - -
-
-
-          
- - {aiHintOffered && } + return ( + <> + {/* Screen readers are already watching it when an error appears. + Announces the title, without moving focus away from the Run button. */} +
+ {error ? t("output.errorMessage.title") : ""} +
+ {error ? ( +
+
+ + + + {t("output.errorMessage.title")} + + + +
+
+
+              
+ + {aiHintOffered && } +
+
-
-
- ) : null; + ) : null} + + ); }; export default ErrorMessage; diff --git a/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx b/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx index 4490707f8..51f623b2d 100644 --- a/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx +++ b/src/components/Editor/ErrorMessage/ErrorMessage.test.jsx @@ -45,13 +45,13 @@ describe("When error is set", () => { }); test("Displays the error title in an expanded details section", () => { - const title = screen.getByText("output.errorMessage.title"); + const title = document.querySelector(".error-message__title"); expect(title.closest("summary")).toBeInTheDocument(); expect(title.closest("details")).toHaveAttribute("open"); }); test("Clicking the title collapses and expands the error details", () => { - const title = screen.getByText("output.errorMessage.title"); + const title = document.querySelector(".error-message__title"); const details = title.closest("details"); fireEvent.click(title); @@ -61,6 +61,12 @@ describe("When error is set", () => { expect(details).toHaveAttribute("open"); }); + test("Announces the error title in a status region", () => { + expect(screen.getByRole("status")).toHaveTextContent( + "output.errorMessage.title", + ); + }); + test("Does not display friendly error elements", () => { expect( document.querySelector(".error-message__friendly"), @@ -158,6 +164,20 @@ describe("When error is set", () => { }); }); +describe("When error is not set", () => { + test("Keeps an empty status region rendered for announcements", () => { + const store = configureStore([])({ editor: { error: "" } }); + render( + + + , + ); + + expect(screen.getByRole("status")).toBeEmptyDOMElement(); + expect(document.querySelector(".error-message")).not.toBeInTheDocument(); + }); +}); + describe("AI hint", () => { const mockStore = configureStore([]); From 6a4e35622367012776d102250abeced0a240c949 Mon Sep 17 00:00:00 2001 From: cocomarine Date: Fri, 20 Nov 2026 12:58:19 +0000 Subject: [PATCH 7/8] remove grey out of error message and update summary title focus colour --- src/assets/stylesheets/ErrorMessage.scss | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/assets/stylesheets/ErrorMessage.scss b/src/assets/stylesheets/ErrorMessage.scss index 1caf08e3b..255d8d22f 100644 --- a/src/assets/stylesheets/ErrorMessage.scss +++ b/src/assets/stylesheets/ErrorMessage.scss @@ -4,7 +4,6 @@ .error-message { color: var(--rpf-red-900); background-color: var(--rpf-red-100); - border-block: 1px solid var(--editor-color-outline); display: flex; flex-direction: column; min-block-size: 0; @@ -32,9 +31,14 @@ &::-webkit-details-marker { display: none; } + + &:focus-visible { + outline: 3px solid var(--editor-focus-color); + outline-offset: -3px; + } } - details[open] &__summary { + details &__summary { border-block: 1px solid var(--rpf-red-200); } From eb2b3dde758a33da6f88e1126b64b95f13733e7d Mon Sep 17 00:00:00 2001 From: cocomarine Date: Fri, 20 Nov 2026 15:17:00 +0000 Subject: [PATCH 8/8] add fallback for those that can't use details-content selector --- src/assets/stylesheets/ErrorMessage.scss | 37 ++++++++++++++++-------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/assets/stylesheets/ErrorMessage.scss b/src/assets/stylesheets/ErrorMessage.scss index 255d8d22f..74d5d2959 100644 --- a/src/assets/stylesheets/ErrorMessage.scss +++ b/src/assets/stylesheets/ErrorMessage.scss @@ -4,22 +4,17 @@ .error-message { color: var(--rpf-red-900); background-color: var(--rpf-red-100); + border-block-start: 1px solid var(--rpf-red-200); display: flex; flex-direction: column; min-block-size: 0; - - details { - display: flex; - flex-direction: column; - min-block-size: 0; - - &::details-content { - min-block-size: 0; - overflow-y: auto; - } - } + overflow-y: auto; &__summary { + position: sticky; + inset-block-start: 0; + background-color: var(--rpf-red-100); + z-index: 1; display: flex; align-items: center; justify-content: space-between; @@ -38,8 +33,26 @@ } } + @supports selector(::details-content) { + overflow-y: visible; + details { + display: flex; + flex-direction: column; + min-block-size: 0; + + &::details-content { + min-block-size: 0; + overflow-y: auto; + } + } + + .error-message__summary { + position: static; + } + } + details &__summary { - border-block: 1px solid var(--rpf-red-200); + border-block-end: 1px solid var(--rpf-red-200); } &__title {