Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
fa32dfd
Added Cypress tests for EuiInlineEdit functionality
breehall Apr 18, 2023
283f8a0
Added snapshots for read mode and edit mode for the Text and Title va…
breehall Apr 18, 2023
1ab4495
Use RTL render method for snapshots
breehall Apr 19, 2023
c405805
[InlineEditForm] - Add data-test-subj to EuiInlineEditForm buttons an…
breehall Apr 19, 2023
9208180
Created test cases for EuiInlineEditForm. These test cases handle the…
breehall Apr 19, 2023
34a11ef
Updated InlineEdit Text and Title test suites to only include basic r…
breehall Apr 19, 2023
f08cd5b
Removed Cypress test in favor of testing EuiInlineEdit with Jest
breehall Apr 19, 2023
598cd09
Created the onSave prop that returns that latest value within EuiFiel…
breehall Apr 19, 2023
6005e53
[REVERT ME] Added text to the InlineEditText example to display the u…
breehall Apr 19, 2023
c591a33
Updated onSave prop test to use the Jest mock function call instead o…
breehall Apr 19, 2023
55878e4
[PR Feedback] Remove tests that toggled between read/edit mode in Eui…
breehall Apr 21, 2023
b113e67
[PR Feedback] - Updated the descriptions for the onSave and onConfirm…
breehall Apr 21, 2023
b9624a8
[PR Feedback] Updated EuiInlineEditForm test cases with more specific…
breehall Apr 21, 2023
3465510
Revert "[REVERT ME] Added text to the InlineEditText example to displ…
breehall Apr 21, 2023
41f0daa
Created a new documentation example to showcase the onSave prop
breehall Apr 21, 2023
7f4f604
Update src-docs/src/views/inline_edit/inline_edit_example.js
breehall Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src-docs/src/views/inline_edit/inline_edit_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const inlineEditTitleSource = require('!!raw-loader!./inline_edit_title');
import InlineEditModeProps from './inline_edit_mode_props';
const inlineEditModePropsSource = require('!!raw-loader!./inline_edit_mode_props');

import InlineEditSave from './inline_edit_save';
const inlineEditSaveSource = require('!!raw-loader!././inline_edit_save');

import InlineEditConfirm from './inline_edit_confirm';
const inlineEditConfirmSource = require('!!raw-loader!././inline_edit_confirm');

Expand All @@ -38,6 +41,7 @@ export const InlineEditExample = {
</EuiText>
</>
),
isNew: true,
sections: [
{
title: 'Display and edit basic text',
Expand Down Expand Up @@ -80,6 +84,26 @@ export const InlineEditExample = {
demo: <InlineEditTitle />,
props: { EuiInlineEditTitle },
},
{
title: 'Saving edited text',
text: (
<>
<p>
Use the <EuiCode>onSave</EuiCode> property to retrieve the value of
the edited text when the save button is pressed, and the{' '}
<EuiCode>onConfirm</EuiCode> callback (if passed) returns{' '}
Copy link
Contributor

@cee-chen cee-chen Apr 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Not a blocking comment - revisiting this in follow-up PR is definitely an option]

Looking at the docs, I'm tempted to either move the onConfirm and onSave examples next to each other or combine them into a single example. It definitely feels like they have similar usages.

We may also need to show consumers how to use onConfirm in combination with the isLoading/isInvalid props to show a loading/invalid state before text gets saved and the component switches back to read mode.

In particular I'm worried about isLoading - typically loading responses for API calls are returned as async promises, which onConfirm does not currently have any allowances for.

<EuiCode>true</EuiCode> .{' '}
</p>
</>
),
source: [
{
type: GuideSectionTypes.TSX,
code: inlineEditSaveSource,
},
],
demo: <InlineEditSave />,
},
{
title: 'Loading and invalid states',
text: (
Expand Down
34 changes: 34 additions & 0 deletions src-docs/src/views/inline_edit/inline_edit_save.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';

import { EuiButton, EuiInlineEditText, EuiSpacer } from '../../../../src';

export default () => {
const saveToLocalStorage = (newInlineEditValue: string) => {
localStorage.setItem('inlineEditValue', newInlineEditValue);
};

const removeFromLocalStorage = () => {
localStorage.removeItem('inlineEditValue');
};

const defaultInlineEditValue =
localStorage.getItem('inlineEditValue') ||
'This value will persist when you refresh the page!';

return (
<>
<EuiInlineEditText
inputAriaLabel="Edit text inline"
defaultValue={defaultInlineEditValue}
size="m"
onSave={(onSaveVal) => saveToLocalStorage(onSaveVal)}
/>

<EuiSpacer />

<EuiButton onClick={removeFromLocalStorage}>
Remove saved value from local storage
</EuiButton>
</>
);
};
Loading