From 1293fb8460cc16de0af11a27ff350a0f59b09ec8 Mon Sep 17 00:00:00 2001 From: "sonarqube-agent[bot]" <210722872+sonarqube-agent[bot]@users.noreply.github.com> Date: Mon, 8 Jun 2026 09:04:06 +0000 Subject: [PATCH] fix: Address 5 SonarQube issues Fixed issues: - AZ4gULnbPbhjpGHKt4ck for typescript:S2699 rule - AZzc7Xbc7Egi-7Bbgag8 for typescript:S3358 rule - AZ4gULz1PbhjpGHKt4cl for typescript:S2699 rule - AZCX_zH4UB9YzXIX1wkI for typescript:S3358 rule - AZ2vZv68ZH2HqB6DnTPX for typescript:S6481 rule Generated by SonarQube Agent (task: df0e14bf-9dc8-4a88-91f1-431adcaad4ea) --- .../InternalShadowRoundButton.tsx | 12 ++++----- .../OakModalCenter/OakModalCenter.test.tsx | 4 +-- .../OakCodeRenderer/OakCodeRenderer.test.tsx | 2 +- .../OakLessonNavItem/OakLessonNavItem.tsx | 14 ++++++----- .../UnstyledChevronAccordion.tsx | 25 +++++++++++++------ 5 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/components/internal-components/InternalShadowRoundButton/InternalShadowRoundButton.tsx b/src/components/internal-components/InternalShadowRoundButton/InternalShadowRoundButton.tsx index 41c4b52cf..7489cb1ab 100644 --- a/src/components/internal-components/InternalShadowRoundButton/InternalShadowRoundButton.tsx +++ b/src/components/internal-components/InternalShadowRoundButton/InternalShadowRoundButton.tsx @@ -159,18 +159,16 @@ export const InternalShadowRoundButton = ( ...rest } = props; + const iconColorFilter = disabled + ? disabledIconColor + : defaultIconColor ?? null; + const icon = iconName && ( ); diff --git a/src/components/messaging-and-feedback/OakModalCenter/OakModalCenter.test.tsx b/src/components/messaging-and-feedback/OakModalCenter/OakModalCenter.test.tsx index bb2fc8c03..052705d86 100644 --- a/src/components/messaging-and-feedback/OakModalCenter/OakModalCenter.test.tsx +++ b/src/components/messaging-and-feedback/OakModalCenter/OakModalCenter.test.tsx @@ -53,13 +53,13 @@ describe(OakModalCenter, () => { it("hides close button when hideCloseButton is true", () => { const onCloseSpy = jest.fn(); - const { queryAllByTestId } = renderWithTheme( + const { queryByTestId } = renderWithTheme( Modal content , ); - expect(queryAllByTestId("close-button")).toBeNull; + expect(queryByTestId("close-button")).toBeNull(); }); it("calls onClose when the backdrop is clicked", () => { diff --git a/src/components/owa/OakCodeRenderer/OakCodeRenderer.test.tsx b/src/components/owa/OakCodeRenderer/OakCodeRenderer.test.tsx index 25de9a461..054f90404 100644 --- a/src/components/owa/OakCodeRenderer/OakCodeRenderer.test.tsx +++ b/src/components/owa/OakCodeRenderer/OakCodeRenderer.test.tsx @@ -20,7 +20,7 @@ describe("OakCodeRenderer", () => { const { getByText } = renderWithTheme( , ); - expect(getByText("output")).toBeInTheDocument; + expect(getByText("output")).toBeInTheDocument(); }); it("matches snapshot", () => { diff --git a/src/components/owa/pupil/lesson/OakLessonNavItem/OakLessonNavItem.tsx b/src/components/owa/pupil/lesson/OakLessonNavItem/OakLessonNavItem.tsx index 5538ec3be..a7473145c 100644 --- a/src/components/owa/pupil/lesson/OakLessonNavItem/OakLessonNavItem.tsx +++ b/src/components/owa/pupil/lesson/OakLessonNavItem/OakLessonNavItem.tsx @@ -156,12 +156,14 @@ export const OakLessonNavItem = ( disabledBackgroundColor, ] = pickColorsForSection(lessonSectionName); - const resolvedBackgroundColor = - isDisabled && disabledBackgroundColor - ? disabledBackgroundColor - : progress === "not-started" - ? notStartedBackgroundColor - : backgroundColor; + let resolvedBackgroundColor; + if (isDisabled && disabledBackgroundColor) { + resolvedBackgroundColor = disabledBackgroundColor; + } else if (progress === "not-started") { + resolvedBackgroundColor = notStartedBackgroundColor; + } else { + resolvedBackgroundColor = backgroundColor; + } return ( { + const { isOpen, onOpenChange, ...accordionProps } = props; + const contextValue = useMemo( + () => ({ isOpen, setOpen: onOpenChange }), + [isOpen, onOpenChange], + ); + return ( + + + + ); +}; + /** * - UnstyledChevronAccordion has a chevron icon that rotates when the accordion is open. * - Unlike InternalChevronAccordion, it has no border effects for hover or focus states. @@ -158,12 +174,7 @@ export const UnstyledChevronAccordion = ( ) => { // Is the accordion being used as a controlled component? if (props.isOpen !== undefined) { - const { isOpen, onOpenChange, ...accordionProps } = props; - return ( - - - - ); + return ; } const { isInitiallyOpen = false, ...accordionProps } = props;