diff --git a/src/components/ComponentDemo/ComponentDemo.js b/src/components/ComponentDemo/ComponentDemo.js index 08de0099403..8a200ecf2f6 100644 --- a/src/components/ComponentDemo/ComponentDemo.js +++ b/src/components/ComponentDemo/ComponentDemo.js @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/label-has-associated-control */ /* eslint-disable import/no-extraneous-dependencies */ import React, { useState, useContext } from 'react'; import getTheme from 'gatsby-theme-carbon/src/components/Code/getTheme'; @@ -84,6 +85,8 @@ const ComponentDemo = ({ children, src, scope, noInline, components }) => { return currentVariant.props.children; }); }; + + const labelText = `Live editor for the ${components[0].label} component`; // TODO max width editor handle multiple clicks use regex for individual props? // allow for write-in props @@ -162,12 +165,16 @@ const ComponentDemo = ({ children, src, scope, noInline, components }) => { )} - setCode(updatedCode)} - className={editorContainer} - /> + + setCode(updatedCode)} + className={editorContainer} + textareaId="live-editor-label" + /> {knobs && ( <> diff --git a/src/components/ComponentDemo/ComponentDemo.module.scss b/src/components/ComponentDemo/ComponentDemo.module.scss index 0850c96d789..880254773ab 100644 --- a/src/components/ComponentDemo/ComponentDemo.module.scss +++ b/src/components/ComponentDemo/ComponentDemo.module.scss @@ -477,3 +477,16 @@ body { } } } + +:global(.live-editor-label) { + position: absolute; + overflow: hidden; + width: 1px; + height: 1px; + padding: 0; + border: 0; + margin: -1px; + clip: rect(0, 0, 0, 0); + visibility: inherit; + white-space: nowrap; +}