-
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] Final screen reader / a11y polish pass #6805
[EuiInlineEdit] Final screen reader / a11y polish pass #6805
Conversation
- it was wrapped around the wrong SR text
- leave role as undefined/unset otherwise, as `span` elements should not have a `heading` role
@1Copenut Safari + VO enter keypresses are working for me locally 🎉 Hoping you can repro + confirm for NVDA+Chrome! |
Preview documentation changes for this PR: https://eui.elastic.co/pr_6805/ |
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 VO (Safari and FF) and NVDA (Chrome and FF) in their respective OSes. Marked improvements in behavior include:
- All pairings are honoring the
Enter
key event to save and return to read-only mode - Read-only text and headings are not reading the
aria-describedby
text - Read-only headings are being recognized and announced. Without redundancy.
- Read-only and active headings appear in the NVDA headings menu.
The one quirk--and I hesitate to call it that--is NVDA behavior on pressing ESC
. Instead of closing and returning to read-only mode, it switches the screen reader into Browse mode and leaves the input open. This is likely software intended behavior, so I'm not going to flag it for improvement. I feel strongly that users will encounter the Save and Cancel buttons when they traverse via arrow keys or pressing Tab.
If you feel this is something that could be fixed easily, let's open it as an enhancement ticket so not to hold up this work.
Thanks @cee-chen !
I think this should be another quick fix / simple |
…ly mode" This reverts commit 0f483bd.
Preview documentation changes for this PR: https://eui.elastic.co/pr_6805/ |
@@ -205,6 +205,7 @@ export const EuiInlineEditForm: FunctionComponent<EuiInlineEditFormProps> = ({ | |||
saveInlineEditValue(); | |||
break; | |||
case keys.ESCAPE: | |||
event.preventDefault(); // NVDA will trigger Browse mode otherwise |
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.
After testing, this fix isn't changing NVDA's behavior, but that's okay. I tested NVDA on a basic input form on MDN's docs pages for a benchmark, and found the "two-step" process to be native behavior.
If a user is moving through the page using arrow keys, NVDA doesn't automatically toggle to Focus made and let users enter text into an input. They must press Enter
to kick the screen reader into Focus mode to type into the input. Pressing ESC
toggles the screen reader back to Browser mode at this point.
Your implementation is following native behavior, so I don't see a need to make a change from what's being done here.
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.
Gah - if it's not affecting NVDA or doing anything, I should remove the line in that case. Will push up a reversion in the main feature branch
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.
This is the nature of screen reader testing. Try, fix, revert, try again. :)
…onents (#6757) * [EuiInlineEdit] Create Component Directory and Base Functionality (#6598) * 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> * [EuiInlineEdit] Add Dynamic Font Sizing & Truncation Styling (#6660) * 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> * [EuiInlineEdit] Creation of the `isLoading` and `isInvalid` Props (#6667) * 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> * [EuiInlineEdit] Create `EuiInlineEdit` Docs (#6697) * 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> * [EuiInlineEdit] Test Cases for `EuiInlineEdit` (#6722) * 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> * [EuiInlineEdit] Refactor multiple props to harden for real-world production 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> * [EuiInlineEdit] Add `onKeyDown` Mapping for Saving and Canceling Edits (#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] Add Playground & Code Snippets (#6743) * [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> * [EuiInlineEdit] DOM cleanup, a11y improvements, and fix breaking `onChange` 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` * Removed unneeded style file and references to it. (#6751) * Update src-docs/src/views/inline_edit/inline_edit_example.js Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com> * Update src/components/inline_edit/inline_edit_form.tsx Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com> * Update src-docs/src/views/inline_edit/inline_edit_example.js Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com> * [EuiInlineEdit] `CHANGELOG` & Copy Linting (#6788) * 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 * [EuiInlineEdit] Create `isReadOnly` Prop for Read Mode (#6777) * [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> * Snapshots * [EuiInlineEdit] Final screen reader / a11y polish pass (#6805) * 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 * Revert Escape preventDefault - not actually doing anything :wompwomp: * [misc UX enhancement] 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 * [mobile] Fix edit mode buttons wrapping to next line in small screens * [misc docs tweaks] - 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) * Add demo section for `startWithEditOpen` prop * [misc cleanup/nits] - rename exported form styles more accurately to their usage - test name casing, + don't use camelCasing for non props --------- 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> Co-authored-by: Trevor Pierce <1Copenut@users.noreply.github.com>
Summary
See commit history
QA
✅ Read-only should not have aria-describedby attribute or SR-only text blocks rendered. ( [EuiInlineEdit] Create
isReadOnly
Prop for Read Mode #6777 (comment) )✅ Read-only headings should no longer announce to VoiceOver as headings twice ( [EuiInlineEdit] Create
isReadOnly
Prop for Read Mode #6777 (comment) ):Enter button consistency ( [EuiInlineEdit] Add
EuiInlineEditText
andEuiInlineEditTitle
components #6757 (comment) ):General checklist