-
Notifications
You must be signed in to change notification settings - Fork 859
[EuiInlineEdit] Allow EuiInlineEdit to be used as a controlled component
#7157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EuiInlineEdit] Allow EuiInlineEdit to be used as a controlled component
#7157
Conversation
…ontrolled component
- Created a DRY useMemo hook to handle switching/updating the value to be used in both read mode/edit mode and between controlled vs uncontrolled configurations - Replace readMode/editMode state variables with useMemo value - Pass new onChange & onCancel props to their respective functions within Inline Edit Form
- Remove the unnecessary passing of inline edit form props from EuiInlineEditText and EuiInlineEditTitle. These components we both importing props like defaultValue, placeholder, etc from InlineEditForm just send them back unchanged. The props transformed / changed within Text and Title remain while the others have been removed.
- Spread {...rest} to the InlineEditForm container div. It was being passed by Text and Title, but was never used.
- Updated snapshots to relflect the above change
…g a section dedicated to the props specific to creating a controlled component
EuiInlineEdit to be used as a controlled component
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7157/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7157/ |
src/components/inline_edit/__snapshots__/inline_edit_text.test.tsx.snap
Outdated
Show resolved
Hide resolved
| import classNames from 'classnames'; | ||
|
|
||
| import { CommonProps } from '../common'; | ||
| import { CommonProps, ExclusiveUnion } from '../common'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome that we got ExclusiveUnion to work after all! I was a little worried it would turn out to be a headache
- Inline Edit Text & Title - add the isReadOnly prop back (it was removed when refactoring these two child components by accident) - Architecture updates from PR feedback
…g inline edit as a controlled component
- Update unit tests to have more specific names and test assertions - Added an additional test for onSave validation
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7157/ |
src/components/inline_edit/__snapshots__/inline_edit_form.test.tsx.snap
Outdated
Show resolved
Hide resolved
- Add undefined fallback for placeholder for snapshot readability - Unit test copy and functionality updates
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7157/ |
…t test cases for clarity in functionality
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7157/ |
cee-chen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Wahoo! Thanks for taking the time to do multiple feedback rounds Bree. This approach feels clean, well-tested, and well-typed. Awesome implementation all around!
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_7157/ |
💚 Build Succeeded
History
|
EUI `88.2.0` ➡️ `88.3.0` ## [`88.3.0`](https://github.com/elastic/eui/tree/v88.3.0) - `EuiGlobalToastList` now shows a "Clear all" button by default once above a certain number of toasts (defaults to 3). This threshold is configurable with the `showClearAllButtonAt` prop ([#7111](elastic/eui#7111)) - Added an optional `onClearAllToasts` callback to `EuiGlobalToastList` ([#7111](elastic/eui#7111)) - Added the `value`, `onChange`, and `onCancel` props that allow `EuiInlineEdit` to be used as a controlled component ([#7157](elastic/eui#7157)) - Added `grabOmnidirectional`, `transitionLeftIn`, `transitionLeftOut`, `transitionTopIn`, and `transitionTopOut` icon glyphs. ([#7168](elastic/eui#7168)) **Bug fixes** - Fixed `EuiInlineEdit` components to correctly spread `...rest` attributes to the parent wrapper ([#7157](elastic/eui#7157)) - Fixed `EuiListGroupItem` to correctly render the `extraAction` button when `showToolTip` is also passed ([#7159](elastic/eui#7159)) **Dependency updates** - Updated `@hello-pangea/dnd` to v16.3.0 ([#7125](elastic/eui#7125)) - Updated `@types/lodash` to v4.14.198 ([#7126](elastic/eui#7126)) **Accessibility** - `EuiAccordion` now correctly respects reduced motion settings ([#7161](elastic/eui#7161)) - `EuiAccordion` now shows a focus outline to keyboard users around its revealed children on open ([#7161](elastic/eui#7161)) **CSS-in-JS conversions** - Converted `EuiSplitPanel` to Emotion ([#7172](elastic/eui#7172))⚠️ As a quick heads up, serverless tests appear to have been extremely flake/failure-prone the last couple weeks, particularly Cypress tests. We've evaluated the listed failures and fixed ones that were related to changes in this PR, and we're relatively confident the remaining failures are not related to changes from EUI. Please let us know if you think this is not the case. --------- Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Cee Chen <[email protected]> Co-authored-by: Jon <[email protected]>
⚠️ NOTE: This PR is a copy of #166292 (which was reverted due to failing Storybook builds). This is the same exact PR but with Storybook building fixed. --- EUI `88.2.0` ➡️ `88.3.0` ## [`88.3.0`](https://github.com/elastic/eui/tree/v88.3.0) - `EuiGlobalToastList` now shows a "Clear all" button by default once above a certain number of toasts (defaults to 3). This threshold is configurable with the `showClearAllButtonAt` prop ([#7111](elastic/eui#7111)) - Added an optional `onClearAllToasts` callback to `EuiGlobalToastList` ([#7111](elastic/eui#7111)) - Added the `value`, `onChange`, and `onCancel` props that allow `EuiInlineEdit` to be used as a controlled component ([#7157](elastic/eui#7157)) - Added `grabOmnidirectional`, `transitionLeftIn`, `transitionLeftOut`, `transitionTopIn`, and `transitionTopOut` icon glyphs. ([#7168](elastic/eui#7168)) **Bug fixes** - Fixed `EuiInlineEdit` components to correctly spread `...rest` attributes to the parent wrapper ([#7157](elastic/eui#7157)) - Fixed `EuiListGroupItem` to correctly render the `extraAction` button when `showToolTip` is also passed ([#7159](elastic/eui#7159)) **Dependency updates** - Updated `@hello-pangea/dnd` to v16.3.0 ([#7125](elastic/eui#7125)) - Updated `@types/lodash` to v4.14.198 ([#7126](elastic/eui#7126)) **Accessibility** - `EuiAccordion` now correctly respects reduced motion settings ([#7161](elastic/eui#7161)) - `EuiAccordion` now shows a focus outline to keyboard users around its revealed children on open ([#7161](elastic/eui#7161)) **CSS-in-JS conversions** - Converted `EuiSplitPanel` to Emotion ([#7172](elastic/eui#7172)) --------- Co-authored-by: Bree Hall <[email protected]> Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Jon <[email protected]>
|
Thanks for this @breehall!! |
Closes #7084 || Previous PR: #7117
Summary
EuiInlineEditTextandEuiInlineEditTitletitle to both be used as controlled components by creating three new props (value,onChange,onCancel).defaultValueOR controlled props (value,onChange,onCancel)EuiInlineEditTextandEuiInlineEditTitleby removing unneeded and duplicated props.QA
View the new controlled component section in the Inline Edit docs
Hello World!General checklist
@defaultif default values are missing) and playground toggles