diff --git a/packages/ui-components/button/src/button.tsx b/packages/ui-components/button/src/button.tsx index d7e704a7db..bf56033f93 100644 --- a/packages/ui-components/button/src/button.tsx +++ b/packages/ui-components/button/src/button.tsx @@ -26,21 +26,8 @@ export interface ButtonProps extends ButtonHTMLAttributes { } export const Button = withTooltip((props: ButtonProps) => { - const { - waiting, - label, - primary, - accent, - plain, - hidden, - active, - big, - round, - outlined, - light, - children, - ...btnProps - } = props; + const { waiting, label, primary, accent, plain, hidden, active, big, round, outlined, light, children, ...btnProps } = + props; if (hidden) { return null; @@ -70,11 +57,7 @@ export const Button = withTooltip((props: ButtonProps) => { // render as button return ( - diff --git a/packages/ui-components/tooltip/src/helpers.ts b/packages/ui-components/tooltip/src/helpers.ts index ab346f1142..b2f291a4e0 100644 --- a/packages/ui-components/tooltip/src/helpers.ts +++ b/packages/ui-components/tooltip/src/helpers.ts @@ -115,8 +115,7 @@ export const computeNextPosition = ({ tooltipBounds, targetBounds, }); - const fitsToWindow = - left >= 0 && top >= 0 && right <= viewportWidth && bottom <= viewportHeight; + const fitsToWindow = left >= 0 && top >= 0 && right <= viewportWidth && bottom <= viewportHeight; if (fitsToWindow) { return { diff --git a/packages/ui-components/tooltip/src/tooltip.test.tsx b/packages/ui-components/tooltip/src/tooltip.test.tsx index b47c337552..c120c29ec8 100644 --- a/packages/ui-components/tooltip/src/tooltip.test.tsx +++ b/packages/ui-components/tooltip/src/tooltip.test.tsx @@ -11,9 +11,7 @@ import React from "react"; import { computeNextPosition, RectangleDimensions } from "./helpers"; import { Tooltip, TooltipPosition } from "./tooltip"; -const getRectangle = ( - parts: Omit, -): RectangleDimensions => { +const getRectangle = (parts: Omit): RectangleDimensions => { assert(parts.right >= parts.left); assert(parts.bottom >= parts.top); @@ -382,33 +380,30 @@ describe("computeNextPosition technical tests", () => { TooltipPosition.TOP_LEFT, TooltipPosition.BOTTOM_RIGHT, TooltipPosition.BOTTOM_LEFT, - ])( - "computes to the %p if there is space and it is specified as a preferred position", - (position) => { - expect( - computeNextPosition({ - preferredPositions: position, - offset: 10, - target: { - getBoundingClientRect: () => - getRectangle({ - top: 50, - left: 50, - bottom: 100, - right: 100, - }), - }, - tooltip: { - getBoundingClientRect: () => ({ - height: 20, - width: 20, + ])("computes to the %p if there is space and it is specified as a preferred position", (position) => { + expect( + computeNextPosition({ + preferredPositions: position, + offset: 10, + target: { + getBoundingClientRect: () => + getRectangle({ + top: 50, + left: 50, + bottom: 100, + right: 100, }), - }, - }), - ).toMatchObject({ - position, - }); - }, - ); + }, + tooltip: { + getBoundingClientRect: () => ({ + height: 20, + width: 20, + }), + }, + }), + ).toMatchObject({ + position, + }); + }); }); }); diff --git a/packages/ui-components/tooltip/src/withTooltip.test.tsx b/packages/ui-components/tooltip/src/withTooltip.test.tsx index abc670f526..3f50c0a986 100644 --- a/packages/ui-components/tooltip/src/withTooltip.test.tsx +++ b/packages/ui-components/tooltip/src/withTooltip.test.tsx @@ -16,14 +16,12 @@ type MyComponentProps = { "data-testid"?: string; }; -const MyComponent = withTooltip( - ({ text, "data-testid": testId, id, children }: MyComponentProps) => ( -
- {text} - {children} -
- ), -); +const MyComponent = withTooltip(({ text, "data-testid": testId, id, children }: MyComponentProps) => ( +
+ {text} + {children} +
+)); describe("withTooltip tests", () => { it("does not render a tooltip when not specified", () => { @@ -42,9 +40,7 @@ describe("withTooltip tests", () => { let result: RenderResult; beforeEach(() => { - result = render( - , - ); + result = render(); }); it("renders", () => { @@ -71,12 +67,7 @@ describe("withTooltip tests", () => { beforeEach(() => { result = render( - , + , ); }); diff --git a/packages/ui-components/tooltip/src/withTooltip.tsx b/packages/ui-components/tooltip/src/withTooltip.tsx index 819b4b1bd4..4b0d828b88 100644 --- a/packages/ui-components/tooltip/src/withTooltip.tsx +++ b/packages/ui-components/tooltip/src/withTooltip.tsx @@ -32,13 +32,7 @@ export function withTooltip( const [defaultTooltipId] = useState(uniqueId("tooltip_target_")); let { id: targetId, children: targetChildren } = props; - const { - tooltip, - tooltipOverrideDisabled, - id: _unusedId, - children: _unusedTargetChildren, - ...targetProps - } = props; + const { tooltip, tooltipOverrideDisabled, id: _unusedId, children: _unusedTargetChildren, ...targetProps } = props; if (tooltip) { const tooltipProps: TooltipProps = {