From d41c55f512399ec532a829b86a15f3db70614e2c Mon Sep 17 00:00:00 2001 From: Nick Peihl Date: Wed, 6 Sep 2023 10:51:41 -0400 Subject: [PATCH 1/4] Display extraAction button in EuiListGroupItem when showTooltip is true --- .../list_group_item.test.tsx.snap | 32 +++++++++++++++++++ .../list_group/list_group_item.test.tsx | 16 ++++++++++ src/components/list_group/list_group_item.tsx | 1 + 3 files changed, 49 insertions(+) diff --git a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap index 604f2a99529..ba4cb106ff5 100644 --- a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap +++ b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap @@ -129,6 +129,38 @@ exports[`EuiListGroupItem props extraAction is rendered 1`] = ` `; +exports[`EuiListGroupItem props extraAction is rendered with showToolTip 1`] = ` +
  • + + + + Label + + + + +
  • +`; + exports[`EuiListGroupItem props href and onClick is rendered 1`] = `
  • { expect(container.firstChild).toMatchSnapshot(); }); + test('is rendered with showToolTip', () => { + const { container } = render( + + ); + + expect(container.firstChild).toMatchSnapshot(); + }); + test('can be disabled', () => { const { container } = render( = ({ > {itemContent} + {extraActionNode}
  • ); } else { From 6e46fb7cb62591e3682436cd84b88da1249bacf4 Mon Sep 17 00:00:00 2001 From: Nick Peihl Date: Wed, 6 Sep 2023 11:52:22 -0400 Subject: [PATCH 2/4] Put extra action button inside EuiToolTip --- .../list_group_item.test.tsx.snap | 24 +++++++++---------- src/components/list_group/list_group_item.tsx | 6 +++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap index ba4cb106ff5..f3fd82ff35e 100644 --- a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap +++ b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap @@ -145,19 +145,19 @@ exports[`EuiListGroupItem props extraAction is rendered with showToolTip 1`] = ` Label + - `; diff --git a/src/components/list_group/list_group_item.tsx b/src/components/list_group/list_group_item.tsx index 70c755b5426..fb44067c111 100644 --- a/src/components/list_group/list_group_item.tsx +++ b/src/components/list_group/list_group_item.tsx @@ -352,9 +352,11 @@ export const EuiListGroupItem: FunctionComponent = ({ anchorClassName={anchorClasses} anchorProps={anchorPropsAndCss} > - {itemContent} + <> + {itemContent} + {extraActionNode} + - {extraActionNode} ); } else { From e32250c76c7ead373d26c052d6568f58692d5d37 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Wed, 6 Sep 2023 10:43:37 -0700 Subject: [PATCH 3/4] [tests cleanup] Remove snapshots in favor of specific assertions + grab the disabled test/snapshot while we're here too --- .../list_group_item.test.tsx.snap | 62 ------------------- .../list_group/list_group_item.test.tsx | 10 +-- 2 files changed, 6 insertions(+), 66 deletions(-) diff --git a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap index f3fd82ff35e..8c9b127f0a2 100644 --- a/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap +++ b/src/components/list_group/__snapshots__/list_group_item.test.tsx.snap @@ -70,36 +70,6 @@ exports[`EuiListGroupItem props color text is rendered 1`] = ` `; -exports[`EuiListGroupItem props extraAction can be disabled 1`] = ` -
  • - - - Label - - - -
  • -`; - exports[`EuiListGroupItem props extraAction is rendered 1`] = `
  • `; -exports[`EuiListGroupItem props extraAction is rendered with showToolTip 1`] = ` -
  • - - - - Label - - - - -
  • -`; - exports[`EuiListGroupItem props href and onClick is rendered 1`] = `
  • { }); test('is rendered with showToolTip', () => { - const { container } = render( + const { getByTestSubject } = render( { iconType: 'empty', alwaysShow: true, 'aria-label': 'label', + 'data-test-subj': 'extraAction', }} /> ); - expect(container.firstChild).toMatchSnapshot(); + expect(getByTestSubject('extraAction')).toBeInTheDocument(); }); test('can be disabled', () => { - const { container } = render( + const { getByTestSubject } = render( ); - expect(container.firstChild).toMatchSnapshot(); + expect(getByTestSubject('extraAction')).toBeDisabled(); }); }); From e1324bfc28f1e48b30464df85ab741873baa5657 Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Wed, 6 Sep 2023 10:45:41 -0700 Subject: [PATCH 4/4] changelog --- upcoming_changelogs/7159.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 upcoming_changelogs/7159.md diff --git a/upcoming_changelogs/7159.md b/upcoming_changelogs/7159.md new file mode 100644 index 00000000000..c848a260326 --- /dev/null +++ b/upcoming_changelogs/7159.md @@ -0,0 +1,3 @@ +**Bug fixes** + +- Fixed `EuiListGroupItem` to correctly render the `extraAction` button when `showToolTip` is also passed