From e126108b787c2bf68463d658473cc0f1e8f82a27 Mon Sep 17 00:00:00 2001
From: Kristóf Marussy <kristof@marussy.com>
Date: Mon, 11 Oct 2021 01:24:39 +0200
Subject: fix(web): a11y issue reported by Lighthouse

---
 language-web/src/main/js/editor/EditorArea.tsx | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'language-web/src/main/js/editor/EditorArea.tsx')

diff --git a/language-web/src/main/js/editor/EditorArea.tsx b/language-web/src/main/js/editor/EditorArea.tsx
index 460005ce..7b6201ed 100644
--- a/language-web/src/main/js/editor/EditorArea.tsx
+++ b/language-web/src/main/js/editor/EditorArea.tsx
@@ -1,7 +1,6 @@
 import { Command, EditorView } from '@codemirror/view';
 import { closeSearchPanel, openSearchPanel } from '@codemirror/search';
 import { closeLintPanel, openLintPanel } from '@codemirror/lint';
-
 import { observer } from 'mobx-react-lite';
 import React, {
   useCallback,
@@ -64,6 +63,13 @@ function usePanel(
   return setCachedViewState;
 }
 
+function fixCodeMirrorAccessibility(editorView: EditorView) {
+  // Reported by Lighthouse 8.3.0.
+  const { contentDOM } = editorView;
+  contentDOM.removeAttribute('aria-expanded');
+  contentDOM.setAttribute('aria-label', 'Code editor');
+}
+
 export const EditorArea = observer(() => {
   const { editorStore } = useRootStore();
   const editorParentRef = useRef<HTMLDivElement | null>(null);
@@ -109,6 +115,7 @@ export const EditorArea = observer(() => {
         }
       },
     });
+    fixCodeMirrorAccessibility(editorView);
     setEditorViewState(editorView);
     setSearchPanelOpen(false);
     setLintPanelOpen(false);
-- 
cgit v1.2.3-70-g09d2

