From 9af5d136a95cadd91c3212080bb060091ce3453d Mon Sep 17 00:00:00 2001 From: tulup-conner Date: Sun, 31 Jul 2022 19:47:02 +0000 Subject: [PATCH] fix(component): display text only on Sidebar.Item tooltip (#315) * fix(component): display text only on `Sidebar.Item` tooltip When a `Sidebar` is collapsed, each item's text content is hidden. You hover over an item to see a `Tooltip` with its text content. That isn't how it worked up until now. resolve #258 * test(component): drop false-positive `Sidebar` tests I don't think we can rely on a fake DOM environment to test hover states correctly. We should write integration tests for `` behavior in `cypress`. --- src/lib/components/Flowbite/FlowbiteTheme.ts | 1 - src/lib/components/Sidebar/Sidebar.spec.tsx | 27 ----------------- .../components/Sidebar/Sidebar.stories.tsx | 2 +- src/lib/components/Sidebar/SidebarItem.tsx | 30 +++++++++++-------- src/lib/components/Sidebar/index.tsx | 2 +- src/lib/theme/default.ts | 3 +- 6 files changed, 20 insertions(+), 45 deletions(-) diff --git a/src/lib/components/Flowbite/FlowbiteTheme.ts b/src/lib/components/Flowbite/FlowbiteTheme.ts index 34b304c6b..873f5f96c 100644 --- a/src/lib/components/Flowbite/FlowbiteTheme.ts +++ b/src/lib/components/Flowbite/FlowbiteTheme.ts @@ -413,7 +413,6 @@ export interface FlowbiteTheme { }; content: { base: string; - collapsed: string; }; icon: { base: string; diff --git a/src/lib/components/Sidebar/Sidebar.spec.tsx b/src/lib/components/Sidebar/Sidebar.spec.tsx index b852b0d89..dc7e401c9 100644 --- a/src/lib/components/Sidebar/Sidebar.spec.tsx +++ b/src/lib/components/Sidebar/Sidebar.spec.tsx @@ -117,30 +117,6 @@ describe.concurrent('Components / Sidebar', () => { }); }); - describe('`Sidebar.Collapse` and `Sidebar.Item`', () => { - it('should display tooltip', () => { - const items = getSidebarItems(render()); - - items.forEach((item) => { - expect(item.firstElementChild).toHaveAttribute('data-testid', 'tooltip-target'); - }); - }); - - it("shouldn't display text content", () => { - const items = getSidebarItemContents(render()); - - items.forEach((item) => expect(item).toHaveClass('hidden')); - }); - }); - - describe('`Sidebar.Item`', () => { - it("shouldn't display `label`", () => { - const labels = getSidebarLabels(render()); - - labels.forEach((label) => expect(label).not.toBeVisible()); - }); - }); - describe('`Sidebar.Logo`', () => { it("shouldn't display text content", () => { const logo = getSidebarLogo(render()); @@ -459,8 +435,5 @@ const getSidebarItems = ({ getAllByRole }: Pick): const getSidebarItemsContainer = ({ getAllByTestId }: Pick): HTMLElement[] => getAllByTestId('flowbite-sidebar-items'); -const getSidebarLabels = ({ queryAllByTestId }: Pick): HTMLElement[] => - queryAllByTestId('flowbite-sidebar-label'); - const getSidebarLogo = ({ getByLabelText }: Pick): HTMLElement => getByLabelText('Flowbite'); diff --git a/src/lib/components/Sidebar/Sidebar.stories.tsx b/src/lib/components/Sidebar/Sidebar.stories.tsx index a5d16510a..32e05a330 100644 --- a/src/lib/components/Sidebar/Sidebar.stories.tsx +++ b/src/lib/components/Sidebar/Sidebar.stories.tsx @@ -184,7 +184,7 @@ CTAButton.args = {
- Beta + Beta