From ec2602dbeede58b48f9305d086bae26ccc3b9da0 Mon Sep 17 00:00:00 2001 From: Bree Hall <40739624+breehall@users.noreply.github.com> Date: Thu, 20 Jul 2023 09:30:55 -0400 Subject: [PATCH] [EuiInlineEdit] Add `title` to Read Mode Button (#6966) * [EuiInlineEdit] Add title prop to EuiEmptyButton in read mode to assist with reading truncated text. * [EuiInlineEdit] Update test cases & snapshots * CHANGELOG * Update upcoming_changelogs/6966.md Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_form.test.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_form.test.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * [PR Feedback] Allow title on read mode button to be overridden; Adjust read mdoe - placeholder test to include checks for the title tooltip. --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> --- .../__snapshots__/inline_edit_form.test.tsx.snap | 5 +++++ .../__snapshots__/inline_edit_text.test.tsx.snap | 5 +++++ .../__snapshots__/inline_edit_title.test.tsx.snap | 8 ++++++++ src/components/inline_edit/inline_edit_form.test.tsx | 11 ++++++++++- src/components/inline_edit/inline_edit_form.tsx | 1 + upcoming_changelogs/6966.md | 1 + 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 upcoming_changelogs/6966.md diff --git a/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap b/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap index 52e6919d341..69d7960e002 100644 --- a/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap +++ b/src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap @@ -739,6 +739,7 @@ exports[`EuiInlineEditForm read mode isReadOnly 1`] = ` class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-disabled-flush-both-isDisabled-euiInlineEditReadMode-isReadOnly" data-test-subj="euiInlineReadModeButton" disabled="" + title="Hello World!" type="button" > { }); test('placeholder', () => { - const { container, getByText } = render( + const { container, getByText, getByTitle } = render( { expect(container.firstChild).toMatchSnapshot(); expect(getByText('This is a placeholder.')).toBeTruthy(); + expect(getByTitle('This is a placeholder.')).toBeTruthy(); + }); + + it('renders the read mode value in a title tooltip', () => { + const { getByTitle } = render( + + ); + + expect(getByTitle('Hello World!')).toBeTruthy(); }); }); diff --git a/src/components/inline_edit/inline_edit_form.tsx b/src/components/inline_edit/inline_edit_form.tsx index 90feb3c86a7..71e611b5e21 100644 --- a/src/components/inline_edit/inline_edit_form.tsx +++ b/src/components/inline_edit/inline_edit_form.tsx @@ -330,6 +330,7 @@ export const EuiInlineEditForm: FunctionComponent = ({ data-test-subj="euiInlineReadModeButton" disabled={isReadOnly} css={readModeCssStyles} + title={readModeValue || placeholder} {...readModeProps} buttonRef={setReadModeRefs} aria-describedby={classNames( diff --git a/upcoming_changelogs/6966.md b/upcoming_changelogs/6966.md new file mode 100644 index 00000000000..8d206a79d99 --- /dev/null +++ b/upcoming_changelogs/6966.md @@ -0,0 +1 @@ +- Updated `EuiInlineEdit`'s read mode button to include a title tooltip, increasing readability of truncated text