-
Notifications
You must be signed in to change notification settings - Fork 842
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] Add EuiInlineEditText
and EuiInlineEditTitle
components
#6757
Conversation
) * Initial directory setup for EuiInlineEdit * Initial structure for EuiInlineEdit docs * Created EuiInlineEdit base component that toggles between a text input and text or title. * Replaced button icons with full EuiButtons with text. Positioned the buttons on the right side of the input * Added early snapshot for component * Added aria-labels with i18n for the editView input, save button, and cancel buttons. Updated the props to require an input aria label because the option to show the label on the input was removed. This was removed to preserve the layout and prevent the input from appearing to bounch when switching between editView and readView. * Combined with last commit - forgot to hit save * Made defaultValue a required field because if there is no value passed in, the button will be empty (with the exception of the edit icon) * Updated basic snapshot tests, updated docs * Added button groups to documentation to make toggling button sizes easier * Update src/components/text/index.ts Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src-docs/src/views/inline_edit/inline_edit.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src-docs/src/views/inline_edit/inline_edit.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit.test.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit.tsx Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co> * Separated the two EuiInlineEdit examples into their own files * Created additional logic to resize buttons and fieldtext elements when when the size of EuiInlineEdit is small or lower. * Created a heading prop to allow consumers to choose the level heading they would like the InlineEdit (title) to be wrapped inside of. If one isn't provided, h2 will be the default. * Updated basic test snapshots for EuiInlineEdit * Updated new i18n tokens to be more explicit about their purpose * Split EuiInlineEdit into three components: EuiInlineEditText, EuiInlineEditTitle, and EuiInlineEditButtons. - Created utils and types file to share common props and utility functions between all three components * Oops * EuiInlineEdit Updates - Updated the onConfirm prop to return a boolean flag that will determine if the text value is saved or not in editMode - Updated edit/read prop variable names - Exported EuiButtonEmptyPropsForButton because it's being used as a type for the new readMode prop - Added base testing files for EuiInlineEditTitle and EuiInlineEditButtons * Remove testing props from inline edit example * Separated repeated logic inside of EuiInlineEditTitle and EuiInlineEditText into a new component called EuiInlineEditForm. This new form component is responsible for the toggling of readMode and editMode for EuiInlineEdit. * Move types to shared internal form component * Pass top-level props instead of in a `props` obj * Remove top level read state, use render prop instead - so that EuiInlineEditForm is completely in charge of state * Remove EuiInlineEditButtons, roll into EuiInlineEditForm as inline * Removed utility in favor of component-specific size logic - while still DRYing out the underlying form sizes being used * Fix types and update snapshots * Clean up type def --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> Co-authored-by: Elizabet Oliveira <elizabet.oliveira@elastic.co> Co-authored-by: Constance Chen <constance.chen.3@gmail.com>
* Created styling for EuiInlineEdit text and title components that adjusts the font-size used within the editMode form control. Added styling to ensure that very long text is truncated inside of the EuiEmptyButton used in readMode * Updated snapshot tests for EuiInlineEdit * Update src/components/inline_edit/inline_edit_title.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_text.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Updated snapshots for EuiInlineEdit test cases after modification in Github UI --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
) * Added isInvalid and isLoading props to EuiInlineEdit components (form, title, text). * [REVERT ME] Added prop toggles to the EuiInlineEditText example for validation * Revert "[REVERT ME] Added prop toggles to the EuiInlineEditText example for validation" This reverts commit b72c9ca. Reverting documentation change that was for PR assistance. It's no longer needed. * Updated EuiInlineEditForm by removing the isLoading prop on the confirm and cancel buttons. Instead, these are wrapped in the skeleton component when loading. * Added a new documentation view for the isLoading prop * Updated the editModeProps property to include the erorr prop from EuiFormRowProps. Additionally wrapped EuiFieldText inside of EuiFormRow. This is to allow consumers to pass an error message to the EuiFormRow when the isValid prop is false. * -[PR Feedback] Removed the onChange method from the loading example and placed it directly on the switch element - Created the isValid documentation example * Remove blunder * Added the skeletonHeight index to sizes object. The Skeleton buttons used when isLoading is true need to be smaller when the form is compressed * [PR Feedback - Update the editModeProps prop to include two sub-objects. This includes one that will be placed on the form row and the other will be placed on the input form control in edit mode * [PR Feedback - Combined the isLoading and isValid prop documentation examples. Removed the isValid example completely. * [PR Feedback - Remove hard coded values used for the EuiSkeletonRectangle height when isLoading is true * Update src/components/inline_edit/inline_edit_form.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_form.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_form.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Updated docs that used the editModeProps prop with EuiInlineEdit * Removed unused code block in EuiInlineEditForm * Update src-docs/src/views/inline_edit/inline_edit_example.js Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * [PR Feedback] - Removed readModeProps from InlineEditTitle example. Allowed Prettier to format the copy on a documentation file --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
* Export the EuiInlineEdit Text and Title prop types * Created docs examples for EuiInlineEdit props * Removed an export for EuiInlineEditTextSizes as devs can drill into Title and Text props for the size * [PR Feedback] - Reorder sections of the EuiInlineEdit docs. Update the copy included in a few examples for better understanding * [Oops] Removed and replaced the EuiInlineEditTextSize import in InlineEdit Text example * Update src-docs/src/views/inline_edit/inline_edit_example.js Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
* Added Cypress tests for EuiInlineEdit functionality * Added snapshots for read mode and edit mode for the Text and Title variations for EuiInlineEdit * Use RTL render method for snapshots * [InlineEditForm] - Add data-test-subj to EuiInlineEditForm buttons and inputs - Removed opinionated save logic that prevented users from being able to save empty strings in editMode * Created test cases for EuiInlineEditForm. These test cases handle the functional and prop testing for both the Text and Title variations of the component * Updated InlineEdit Text and Title test suites to only include basic render tests and snapshots of their sizing in both readMode and editMode * Removed Cypress test in favor of testing EuiInlineEdit with Jest * Created the onSave prop that returns that latest value within EuiFieldText (in editMode) at the time the save button is clicked. * [REVERT ME] Added text to the InlineEditText example to display the use of the onSave prop * Updated onSave prop test to use the Jest mock function call instead of relying on variable value changes * [PR Feedback] Remove tests that toggled between read/edit mode in EuiInlineEdit Text and Title test suites. * [PR Feedback] - Updated the descriptions for the onSave and onConfirm props - Removed data-test-subj IDs from the loading skeleton rectangles - Updated the isLoading prop to default to false and removed explicit declarations in Text and Title * [PR Feedback] Updated EuiInlineEditForm test cases with more specific cases for onSave. Removed the isLoading default set in the props for the form as it's no longer needed * Revert "[REVERT ME] Added text to the InlineEditText example to display the use of the onSave prop" This reverts commit 6005e53. Removing modifications to docs file as they were only needed for testing * Created a new documentation example to showcase the onSave prop * Update src-docs/src/views/inline_edit/inline_edit_example.js Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
…uction usage + misc cleanup (#6735) * Save example misc cleanup - remove button that clears localStorage - it's not necessary for the demo and we can do so in devtools instead - remove onConfirm doc copy - going to move that to a new section * Add support for async saving + validation - remove confusing extra `onConfirm` callback for handling everything in a single `onSave` - remove extra `onSave` prop test - just roll that behavior into the last describe block * Update documentation examples - update confirm example to more closely mimic production behavior - remove dedicated isLoading/isInvalid demo - we can demo that in the production example instead * Remove specific `ariaLabel` props in favor of generic props that can be spread to the save & cancel buttons - this is necessary for consumers to do things like reset errors on cancel, or fire telemetry events on click + remove `disabled` state of save button on `isInvalid` - but consumers can add that back in if needed via `saveButtonProps`, depending on their specific UX + minor type cleanup * Support custom `onClick` events for all button props - clicks should call both internal EUI handlers and consumer callbacks * Misc cleanup - Remove unnecessary toggle on isEditing switches which could potentially create race conditions - we know it should always be either true or false depending on the mode being entered/exited - Improve prop docs readability - make `it` vs. `test` syntax/grammar more consistent - Remove unnecessary false fallbacks - undefined is already falsy * Improve docs a bit more - react typegen is mutilating `editModeProps`, so we should more explicit in our manual prop docs - update the last docs example * PR feedback: typo Co-authored-by: Bree Hall <40739624+breehall@users.noreply.github.com> --------- Co-authored-by: Bree Hall <40739624+breehall@users.noreply.github.com>
#6742) * [EuiInlineEdit] Add keydown events that map the Enter and Escape keys to the save and cancel functions respectively. * [REVERT ME] Added a custom keydown event that overrides our Enter mapping as an example * [PR Feedback] Various structural updates including renaming test cases and updating logic to run both the default and custom onKeyDown methods for the edit mode input. * [PR Feedback] Remove autoFocus from both the read mode button and edit mode input in favor of manual focus management. Created a ref/useEffect combo that keeps track of the state and sets focus on the edit mode input only when the read mode button is clicked. * Add aria-describedby property to the edit mode input * Revert commit c48ee4f. * Revert 2460856 * Pull aria-describedby outside of the edit mode input form row * Update test case to validate that custom onKeyDown events work along side the default events
* [EuiInlineEdit] Create a playground for both EuiInlineEdit Text and Title * [EuiInlineEdit] Add code snippets for each InlineEdit example in the docs * Removed the inline edit validation code snippet in favor of the DemoJS because it's more helpful * Small updates to DRY util. * Added the span option to the list of headings available for EuiInlineEdit Title. * Update EuiInlineEdit Title heading prop documentation for clarity * Update src/components/inline_edit/inline_edit_title.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
…hange` bug (#6746) * DOM cleanup - Remove unnecessary `EuiForm` - we're not taking advantage of form submit behavior, so we might as well remove this - Remove unnecessary `EuiFormRow`s around save/cancel buttons - they're not inputs and don't need form rows - Remove incorrect `className={classes}` placement * Use `EuiSkeletonLoading` instead of 2 `EuiSkeletonRectangle`s - this prevents double loading screen reader announcements * Update EuiInlineEdit to only announce when state flips to loading - so that a "loaded" announcement doesn't occur whenever edit mode is opened, which doesn't make a whole lot of sense * Improve SR UX of read mode - add an `aria-describedby` that explains to screen reader users what happens when the read mode button is clicked, since the text itself is not indicative + cleanup: remove unused input ID * Fix `editModeProps.inputProps.onChange` overriding/breaking behavior * Remove `autoFocus` in favor of imperative `.focus()` calls on click - rAF is needed to wait a tick after state has changed and DOM node is available + write tests (with waitFor) asserting that focus state works as expected (mocking rAF primarily for test/function coverage) * [PR feedback] `toggle`->`activate`
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
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.
Thank you for putting together such a comprehensive PR @breehall ! I have a few change requests around screen reader and docs copy. LMK if you want to chat about these or feel I'm off base with suggested changes.
Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com>
Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com>
Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com>
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
* Changelog & text linting from changes made in Github UI * Snapshot update as a result of updating the copy of the aria-describedby used by inline edit
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
* [EuiInlineEdit] Add the isReadOnly prop that locks the component in read mode and does not allow the user to update text * [EuiInlineEdit] Update snapshots to account for new inline_edit_form styles. Added a test case for the new isReadOnly prop * [EuiInlineEdit] Forgot to add snapshot updates * [REVERT] Add documentation example to InlineEdit Text to display isReadOnly prop * Revert "[REVERT] Add documentation example to InlineEdit Text to display isReadOnly prop" This reverts commit 8a7b117. Revert change made to demo for testing * [PR Review] - Add an official example for the isReadOnly prop - Name correction in edit mode props example * [PR Feedback] - Updated the name of Emotion style object to indicate we're styling the read mode button, not the entire form - Conditionally hide the text content of aria-describedby when isReadOnly is true - Conditionally add a role (and aria-level where required) to the read mode button when isReadOnly is true * Update and add test cases * [PR Feedback] - Update conditional aria-describedby span to surround the text instead of the entire span. - Clean up logic related to adding aria-live and role attributes when isReadOnly is true * Update src-docs/src/views/inline_edit/inline_edit_read_only.tsx Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_form.styles.ts Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * [PR Feedback] -Add note in inline_edit_form.style.ts that we should reevaluate styles once EuiEmptyButton is converted to Eotion. - Updated render condition for edit mode to ensure if isReadOnly is true, we stay / kick back to read mode - Test case & snapshot updates * [PR Feedback] Move the isReadOnly prop example up in the documentation * Snapshots * Update src-docs/src/views/inline_edit/inline_edit_example.js Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com> * [PR Feedback] - Removed conditiona lo logic to force a toggle from read mode to edit mode when isReadOnly is true. Opted for a useEffect that will handle the change instead * Oops! --------- Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
* Fix conditional readonly aria-describedby - it was wrapped around the wrong SR text * Prevent double heading roles when readonly - leave role as undefined/unset otherwise, as `span` elements should not have a `heading` role * (hopefully) Fix enter screen reader behavior * Fix VO announcing EuiInlineEditText as `clickable` in read only mode * Revert "Fix VO announcing EuiInlineEditText as `clickable` in read only mode" This reverts commit 0f483bd. * NVDA browser mode fix
@1Copenut I'm planning on doing a final sweep / QA pass on this PR tomorrow and merging it in if everything looks good. Do you mind changing your review if everything looks good on your end a11y-wise as well? |
EuiInlineEdit
Component to EUIEuiInlineEditText
and EuiInlineEditTitle
components
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
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.
👍 LGTM! And sounds good too! I retested with VoiceOver on FF and Safari, and NVDA on FF and Chrome. I left one comment about the event.preventDefault()
on ESC not changing NVDA behavior and that's okay because it's following native behavior in both browsers.
This great work team!
- not actually doing anything :wompwomp:
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
Set `readOnly` on input / prevent further user editing when saving & is in `isLoading` state - docs only improvement as I don't want to tie the two props together (slightly opinionated), but hopefully consumers copy it
- add `size` props to text/title snippets - move longer mode props snippet further down to match location on page - reorder props in demos by relative importance/requirement (or remove if not important)
- rename exported form styles more accurately to their usage - test name casing, + don't use camelCasing for non props
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.
Preview documentation changes for this PR: https://eui.elastic.co/pr_6757/ |
## Summary `eui@81.0.0` ⏩ `eui@81.2.0` - Most changes to source code in this PR are CSS cleanups/deprecations in `EuiSuperDatePicker`/`EuiDatePickerRange` - One team (ML) had a `inline` specific usage of `EuiDatePickerRange` that they reached out to us about via Slack, and that we have fixed in this PR. - All other usages of date picker components should have remained working as-is with no changes, but please ping us if you see otherwise! ___ ## [`81.2.0`](https://github.com/elastic/eui/tree/v81.2.0) - Updated `EuiSuperDatePicker` to accept an object configuration for `isDisabled` ([#6821](elastic/eui#6821)) **Bug fixes** - Fixed broken `EuiSuperDatePicker` styles ([#6821](elastic/eui#6821)) ## [`81.1.0`](https://github.com/elastic/eui/tree/v81.1.0) - Added `EuiInlineEditText` and `EuiInlineEditTitle` components ([#6757](elastic/eui#6757)) - Updated `EuiDatePickerRange` to support `inline` display ([#6795](elastic/eui#6795)) - Added an `onError` callback prop to `EuiErrorBoundary` ([#6810](elastic/eui#6810)) - Updated `EuiDataGrid` to only render screen reader text announcing cell position if the cell is currently focused. This should improve the ability to copy and paste multiple cells without SR text. ([#6817](elastic/eui#6817)) **Bug fixes** - Fixed `EuiDatePicker`'s `inline` display to correctly render and prevent user interaction when `disabled` or `readOnly` ([#6795](elastic/eui#6795)) - Fixed `EuiDatePicker`'s `inline` display to correctly render `isInvalid` and `isLoading` icons ([#6795](elastic/eui#6795)) **CSS-in-JS conversions** - Converted `EuiDatePickerRange` to Emotion ([#6795](elastic/eui#6795)) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Fixes #3928
Summary
This PR merges the
EuiInlineEdit
feature branch into main. For individual PRs into this feature branch, see the git commit history and discrete PR links.QA
Testing Inline Edit
🌟 Inline Edit Staging
readMode
button activateseditMode
readMode
button is compressed when a small size is usedxs
ands
sizesxxxs
,xxs
,xs
, ands
sizesreadMode
button text size should correspond to the text size determined by thesize
propreadMode
button for Inline Edit Title should be wrapped the heading determined by theheading
propThe text inside of thereadMode
button for Inline Edit Text should be wrapped in a<p>
editMode
input passed in viaeditModeProps.inputProps
editMode
form row passed in viaeditModeProps.formRowProps
editMode
save button passed in viaeditModeProps.saveButtonProps
editMode
cancel button passed in viaeditModeProps.cancelButtonProps
isLoading
prop (when active) renders loading skeletons and prevents the user from canceling / savingisInvalid
prop (when active) displays a warning icon on the form row and any additional validation messages passed in via editModeProps.formRowProps. It does not prevent the user from canceling / saving.Selecting the
readMode
button, changing the text in the form control, and selecting the save button or usingEnter
on the keyboard should save your changes and update thereadMode
button text.Selecting the
readMode
button, changing the text in the form control, and selecting the cancel button or usingEscape
on the keyboard should cancel your changes and should not thereadMode
button text.General checklist
@default
if default values are missing) and playground toggles- [ ] Checked Code Sandbox works for any docs examples- [ ] Checked for breaking changes and labeled appropriately- [ ] Updated the Figma library counterpart- internal task for designers opened separately