Skip to content

Commit

Permalink
[EuiInlineEdit] Add title to Read Mode Button (#6966)
Browse files Browse the repository at this point in the history
* [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>
  • Loading branch information
breehall and cee-chen authored Jul 20, 2023
1 parent 08e234e commit ec2602d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<span
Expand Down Expand Up @@ -766,6 +767,7 @@ exports[`EuiInlineEditForm read mode placeholder 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode-hasPlaceholder"
data-test-subj="euiInlineReadModeButton"
title="This is a placeholder."
type="button"
>
<span
Expand Down Expand Up @@ -799,6 +801,7 @@ exports[`EuiInlineEditForm read mode readModeProps 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-primary-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -832,6 +835,7 @@ exports[`EuiInlineEditForm read mode renders 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -865,6 +869,7 @@ exports[`EuiInlineEditForm read mode sizes 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exports[`EuiInlineEditText isReadOnly 1`] = `
data-test-subj="euiInlineReadModeButton"
disabled=""
role="paragraph"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -41,6 +42,7 @@ exports[`EuiInlineEditText renders 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -78,6 +80,7 @@ exports[`EuiInlineEditText text sizes renders m 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -115,6 +118,7 @@ exports[`EuiInlineEditText text sizes renders s 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -152,6 +156,7 @@ exports[`EuiInlineEditText text sizes renders xs 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`EuiInlineEditTitle isReadOnly 1`] = `
data-test-subj="euiInlineReadModeButton"
disabled=""
role="heading"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -43,6 +44,7 @@ exports[`EuiInlineEditTitle renders 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -80,6 +82,7 @@ exports[`EuiInlineEditTitle title sizes renders size l 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -117,6 +120,7 @@ exports[`EuiInlineEditTitle title sizes renders size m 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-m-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -154,6 +158,7 @@ exports[`EuiInlineEditTitle title sizes renders size s 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -191,6 +196,7 @@ exports[`EuiInlineEditTitle title sizes renders size xs 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -228,6 +234,7 @@ exports[`EuiInlineEditTitle title sizes renders size xxs 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down Expand Up @@ -265,6 +272,7 @@ exports[`EuiInlineEditTitle title sizes renders size xxxs 1`] = `
aria-describedby="inlineEdit_generated-id"
class="euiButtonEmpty emotion-euiButtonDisplay-euiButtonEmpty-s-empty-text-flush-both-euiInlineEditReadMode"
data-test-subj="euiInlineReadModeButton"
title="Hello World!"
type="button"
>
<span
Expand Down
11 changes: 10 additions & 1 deletion src/components/inline_edit/inline_edit_form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('EuiInlineEditForm', () => {
});

test('placeholder', () => {
const { container, getByText } = render(
const { container, getByText, getByTitle } = render(
<EuiInlineEditForm
{...commonInlineEditFormProps}
defaultValue=""
Expand All @@ -87,6 +87,15 @@ describe('EuiInlineEditForm', () => {

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(
<EuiInlineEditForm {...commonInlineEditFormProps} />
);

expect(getByTitle('Hello World!')).toBeTruthy();
});
});

Expand Down
1 change: 1 addition & 0 deletions src/components/inline_edit/inline_edit_form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export const EuiInlineEditForm: FunctionComponent<EuiInlineEditFormProps> = ({
data-test-subj="euiInlineReadModeButton"
disabled={isReadOnly}
css={readModeCssStyles}
title={readModeValue || placeholder}
{...readModeProps}
buttonRef={setReadModeRefs}
aria-describedby={classNames(
Expand Down
1 change: 1 addition & 0 deletions upcoming_changelogs/6966.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Updated `EuiInlineEdit`'s read mode button to include a title tooltip, increasing readability of truncated text

0 comments on commit ec2602d

Please sign in to comment.