[Monaco editor]: Fix accessibility focus trap issue#107292
[Monaco editor]: Fix accessibility focus trap issue#107292alisonelizabeth merged 30 commits intoelastic:masterfrom
Conversation
72f772b to
2c845f7
Compare
|
Pinging @elastic/kibana-accessibility (Project:Accessibility) |
|
Pinging @elastic/kibana-stack-management (Team:Stack Management) |
Co-authored-by: Tim Roes <mail@timroes.de>
|
@elasticmachine merge upstream |
timroes
left a comment
There was a problem hiding this comment.
I've changed the wording for readOnly mode:
There is unfortunately another bug left. When the editor can be scrolled out of view the tooltip is potentially attached out of view too, as you can see (or rather not see) in the following screenshot:
To reproduce that go to Discover when having doc_table:legacy turned off in your advanced setting and open a document and go to the JSON tab.
Since this was one of the initial problems, that we wanted the tooltip to solve, @cchaos do you have any idea how to fix that with the tooltip?
cchaos
left a comment
There was a problem hiding this comment.
I'm not sure we can fully handle the situation where the editor is so long that it's height is greater than it's container. We are currently relying on the browser's innate functionality to ensure that it is visible within the scroll container, which is a win. But neither the overlay nor the tooltip solution seem to handle this scenario well. I'm ok with this behavior as it also is one that's only seen when using keyboard + mouse (a rare-er scenario).
But I do agree with @timroes that we should get rid of the overlay background entirely. There's no need to obscure the text. In fact, it just forces the user to have to interact with the code editor in order to read it which is not ideal.
Question: When I'm in edit mode, and hit tab, it takes me out of the editor. Is this supposed to happen?
Also I'd love for @myasonik to have the final pass at this before he leaves us 😢
| <div> | ||
| <EuiText> | ||
| <p> | ||
| {isReadOnly ? ( | ||
| <FormattedMessage | ||
| id="kibana-react.kibanaCodeEditor.startEditingReadOnly" | ||
| defaultMessage="Press Enter to start interacting with the code." | ||
| /> | ||
| ) : ( | ||
| <FormattedMessage | ||
| id="kibana-react.kibanaCodeEditor.startEditing" | ||
| defaultMessage="Press Enter to start editing." | ||
| /> | ||
| )} | ||
| </p> | ||
| </EuiText> | ||
|
|
||
| <EuiText> | ||
| <p> | ||
| {isReadOnly ? ( | ||
| <FormattedMessage | ||
| id="kibana-react.kibanaCodeEditor.stopEditingReadOnly" | ||
| defaultMessage="Press Escape to stop interacting with the code." | ||
| /> | ||
| ) : ( | ||
| <FormattedMessage | ||
| id="kibana-react.kibanaCodeEditor.stopEditing" | ||
| defaultMessage="Press Escape to stop editing." | ||
| /> | ||
| )} | ||
| </p> | ||
| </EuiText> | ||
| </div> |
There was a problem hiding this comment.
The EuiTooltip already has text styles applied to it so this can be simplified to:
| <div> | |
| <EuiText> | |
| <p> | |
| {isReadOnly ? ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.startEditingReadOnly" | |
| defaultMessage="Press Enter to start interacting with the code." | |
| /> | |
| ) : ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.startEditing" | |
| defaultMessage="Press Enter to start editing." | |
| /> | |
| )} | |
| </p> | |
| </EuiText> | |
| <EuiText> | |
| <p> | |
| {isReadOnly ? ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.stopEditingReadOnly" | |
| defaultMessage="Press Escape to stop interacting with the code." | |
| /> | |
| ) : ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.stopEditing" | |
| defaultMessage="Press Escape to stop editing." | |
| /> | |
| )} | |
| </p> | |
| </EuiText> | |
| </div> | |
| <> | |
| <p> | |
| {isReadOnly ? ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.startEditingReadOnly" | |
| defaultMessage="Press Enter to start interacting with the code." | |
| /> | |
| ) : ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.startEditing" | |
| defaultMessage="Press Enter to start editing." | |
| /> | |
| )} | |
| </p> | |
| <p> | |
| {isReadOnly ? ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.stopEditingReadOnly" | |
| defaultMessage="Press Escape to stop interacting with the code." | |
| /> | |
| ) : ( | |
| <FormattedMessage | |
| id="kibana-react.kibanaCodeEditor.stopEditing" | |
| defaultMessage="Press Escape to stop editing." | |
| /> | |
| )} | |
| </p> | |
| </> |
There was a problem hiding this comment.
And it looks like according to the writing guidelines the key references should be exactly whats on the keyboard, plus capitalization and bold. So it should render as:
Press Esc to stop editing.
There was a problem hiding this comment.
@cchaos Could you refer me to the exact part of the writing guidelines? I am not finding it anywhere in https://elastic.github.io/eui/#/guidelines/writing
I am mainly asking because I wonder what that means for "Enter" above? I mean the key does not state "Enter" on most keyboard, but has a symbol on it, are we trying to use that symbol in that case too?
There was a problem hiding this comment.
Sorry, I had meant to link to the doc I got them from (had to ask a UX writer): https://wiki.elastic.co/display/DOC/On+text+highlighting
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
This should only happen in |
Thanks, yeah! I forgot that the one in Discover is |
myasonik
left a comment
There was a problem hiding this comment.
LGTM!
Code review and tested in VoiceOver. A great fix for a broad feature!
|
@cchaos Do you have time to review and update your request for changes? We're trying to get this in today. Thanks! |
|
@cjcenizal I was waiting for the changes to the rendered format of the keys displayed in the tooltip: #107292 (comment) |
|
OK thanks, I'll let @timroes handle that -- he is taking this PR up now that Seb is on PTO. |
💚 Build SucceededMetrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
# Conflicts: # src/plugins/kibana_react/public/code_editor/__snapshots__/code_editor.test.tsx.snap # src/plugins/kibana_react/public/code_editor/code_editor.tsx # x-pack/plugins/canvas/public/components/expression_input/__stories__/__snapshots__/expression_input.stories.storyshot
…108386) * [Monaco editor]: Fix accessibility focus trap issue (#107292) # Conflicts: # src/plugins/kibana_react/public/code_editor/__snapshots__/code_editor.test.tsx.snap # src/plugins/kibana_react/public/code_editor/code_editor.tsx # x-pack/plugins/canvas/public/components/expression_input/__stories__/__snapshots__/expression_input.stories.storyshot * update canvas snapshot Co-authored-by: Sébastien Loix <sabee77@gmail.com>


fixes #72677
This PR fixes an accessibility issue with the
<CodeEditor />component from thekibana_reactplugin where a user would not be able to exit the editor with a keyboard.Hitting the ESC key will now display an overlay to the user that allows him to navigate to the next element on the page.
How to test
emi---> you should have the suggestion menu openNote on implementation
I decided to mock the
MonacoEditorcomponent in order to be able to not test implementation detail of the<CodeEditor />and call methods on the component directly. This allows us to have an<textarea />rendered in our test and interact with it.