Skip to content

Commit

Permalink
Merge branch 'main' into sharp-country-symbol-css
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanaMMoreira authored May 8, 2024
2 parents 705e565 + d972d20 commit 5b3dc85
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-dingos-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@salt-ds/core": patch
---

Fixed `Tooltip` not displaying when the `content` prop value is falsy e.g. 0
14 changes: 14 additions & 0 deletions packages/core/src/__tests__/__e2e__/tooltip/Tooltip.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ describe("GIVEN a Tooltip", () => {
});
});

describe("WHEN content is undefined", () => {
it("then tooltip doesn't display", () => {
cy.mount(<Open content={undefined} />);
cy.findByRole("tooltip").should("not.exist");
});
});

describe("WHEN content is falsy", () => {
it("then tooltip should still display", () => {
cy.mount(<Open content={0} />);
cy.findByRole("tooltip").should("exist");
});
});

describe("WHEN used in header tag", () => {
it("then tooltip displays default font weight and size", () => {
cy.mount(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
);

const floatingRef = useForkRef<HTMLDivElement>(floating, ref);
const hasContent = !!content;
const hasContent = content != undefined && content !== "";

return (
<>
Expand Down
1 change: 1 addition & 0 deletions packages/core/stories/tooltip/tooltip.qa.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const AllExamplesGrid: StoryFn<QAContainerProps> = (props) => {
<IconWithTooltip status="error" content="Error" />
<IconWithTooltip status="success" content="Success" />
<IconWithTooltip status="warning" content="Warning" />
<IconWithTooltip content={0} />
<div
style={{
width: 10,
Expand Down

0 comments on commit 5b3dc85

Please sign in to comment.