From cc07944ad75c6d36cccfae697d1813bccee1cc54 Mon Sep 17 00:00:00 2001 From: Liam Smith Date: Thu, 31 Oct 2024 22:47:46 +0000 Subject: [PATCH 1/3] Fix tooltip status override --- .../__tests__/__e2e__/tooltip/Tooltip.cy.tsx | 24 +++++++++++++++++++ packages/core/src/tooltip/Tooltip.tsx | 5 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/core/src/__tests__/__e2e__/tooltip/Tooltip.cy.tsx b/packages/core/src/__tests__/__e2e__/tooltip/Tooltip.cy.tsx index 572ecff4b2c..034093e11b5 100644 --- a/packages/core/src/__tests__/__e2e__/tooltip/Tooltip.cy.tsx +++ b/packages/core/src/__tests__/__e2e__/tooltip/Tooltip.cy.tsx @@ -257,4 +257,28 @@ describe("GIVEN a Tooltip", () => { cy.findByTestId(FLOATING_TEST_ID).should("exist"); }); }); + + describe("WHEN used in a FormField", () => { + it("AND status is undefined, THEN should inherit status", () => { + cy.mount( + + + + + , + ); + cy.findByRole("tooltip").should("have.class", "saltTooltip-error"); + }); + + it("AND status is defined, THEN should not inherit status", () => { + cy.mount( + + + + + , + ); + cy.findByRole("tooltip").should("have.class", "saltTooltip-info"); + }); + }); }); diff --git a/packages/core/src/tooltip/Tooltip.tsx b/packages/core/src/tooltip/Tooltip.tsx index 654c9844304..2efae0bfc44 100644 --- a/packages/core/src/tooltip/Tooltip.tsx +++ b/packages/core/src/tooltip/Tooltip.tsx @@ -96,10 +96,11 @@ export const Tooltip = forwardRef( const disabled = disabledProp || formFieldDisabled; const status = - formFieldValidationStatus !== undefined && + statusProp ?? + (formFieldValidationStatus !== undefined && VALIDATION_NAMED_STATUS.includes(formFieldValidationStatus) ? formFieldValidationStatus - : statusProp; + : undefined); const { Component: FloatingComponent } = useFloatingComponent(); const hookProps: UseTooltipProps = { From fe69f15133d2f84bbe3fc440b340383055dfca7c Mon Sep 17 00:00:00 2001 From: Liam Smith Date: Thu, 31 Oct 2024 23:21:48 +0000 Subject: [PATCH 2/3] Update changeset --- .changeset/slow-bags-give.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/slow-bags-give.md diff --git a/.changeset/slow-bags-give.md b/.changeset/slow-bags-give.md new file mode 100644 index 00000000000..f2fe3fdc8fd --- /dev/null +++ b/.changeset/slow-bags-give.md @@ -0,0 +1,5 @@ +--- +"@salt-ds/core": patch +--- + +Fixed Tooltip to prioritize it's `status` prop over the status inherited from a parent FormField. From de6010678b938eed65c9d85a736e1819009b96cf Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:09:16 +0000 Subject: [PATCH 3/3] Update slow-bags-give.md --- .changeset/slow-bags-give.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/slow-bags-give.md b/.changeset/slow-bags-give.md index f2fe3fdc8fd..6bedbdadf18 100644 --- a/.changeset/slow-bags-give.md +++ b/.changeset/slow-bags-give.md @@ -2,4 +2,4 @@ "@salt-ds/core": patch --- -Fixed Tooltip to prioritize it's `status` prop over the status inherited from a parent FormField. +Fixed Tooltip to prioritize its `status` prop over the status inherited from a parent FormField.