Skip to content

Commit

Permalink
fix: [Stateful: Home page] Wrong announcement of code editor (#195922)
Browse files Browse the repository at this point in the history
Closes: #195289
Closes: #195198
Closes: #195358

## Description 

- The text editor must be fully accessible and functional across all
devices, ensuring users can edit text using various input methods, not
just a mouse. This functionality should be available in both the
expanded and collapsed states.

- Appropriate aria-label attribute must be assigned to elements to
provide users with clear context and understanding of the type of
element they are interacting with. This enhances usability and
accessibility for all users.

## What was changed: 

- Updated the aria-label attribute for the editor button to improve
accessibility.
- Resolved an issue with the background color when activating
full-screen mode from the dialog.
- Fixed keyboard navigation for full-screen mode, enabling users to
activate Edit Mode using only the keyboard.

## Screen 


https://github.com/user-attachments/assets/af122fab-3ce9-4a7f-b8b1-d75d39969781
  • Loading branch information
alexwizp authored Oct 15, 2024
1 parent 8cceaee commit 04efa04
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 10 additions & 3 deletions packages/shared-ux/code_editor/impl/code_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
role="button"
onClick={startEditing}
onKeyDown={onKeyDownHint}
aria-label={ariaLabel}
aria-label={i18n.translate('sharedUXPackages.codeEditor.codeEditorEditButton', {
defaultMessage: '{codeEditorAriaLabel}, activate edit mode',
values: {
codeEditorAriaLabel: ariaLabel,
},
})}
data-test-subj={`codeEditorHint codeEditorHint--${isHintActive ? 'active' : 'inactive'}`}
/>
</EuiToolTip>
Expand Down Expand Up @@ -528,6 +533,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({
</div>
) : null}
<UseBug177756ReBroadcastMouseDown>
{accessibilityOverlayEnabled && isFullScreen && renderPrompt()}
<MonacoEditor
theme={theme}
language={languageId}
Expand Down Expand Up @@ -576,6 +582,7 @@ export const CodeEditor: React.FC<CodeEditorProps> = ({

const useFullScreen = ({ allowFullScreen }: { allowFullScreen?: boolean }) => {
const [isFullScreen, setIsFullScreen] = useState(false);
const { euiTheme } = useEuiTheme();

const toggleFullScreen = () => {
setIsFullScreen(!isFullScreen);
Expand Down Expand Up @@ -617,12 +624,12 @@ const useFullScreen = ({ allowFullScreen }: { allowFullScreen?: boolean }) => {
return (
<EuiOverlayMask>
<EuiFocusTrap clickOutsideDisables={true}>
<div css={styles.fullscreenContainer}>{children}</div>
<div css={styles.fullscreenContainer(euiTheme)}>{children}</div>
</EuiFocusTrap>
</EuiOverlayMask>
);
},
[isFullScreen]
[isFullScreen, euiTheme]
);

return {
Expand Down
3 changes: 2 additions & 1 deletion packages/shared-ux/code_editor/impl/editor.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export const styles = {
position: relative;
height: 100%;
`,
fullscreenContainer: css`
fullscreenContainer: (euiTheme: EuiThemeComputed) => css`
position: absolute;
left: 0;
top: 0;
background: ${euiTheme.colors.body};
`,
keyboardHint: (euiTheme: EuiThemeComputed) => css`
position: absolute;
Expand Down

0 comments on commit 04efa04

Please sign in to comment.