-
Notifications
You must be signed in to change notification settings - Fork 101
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
fix(ui-source-code-editor): link label to input field programmatically #1865
fix(ui-source-code-editor): link label to input field programmatically #1865
Conversation
|
@@ -655,7 +665,7 @@ class SourceCodeEditor extends Component<SourceCodeEditorProps> { | |||
omitProps(restProps, SourceCodeEditor.allowedProps) | |||
)} | |||
> | |||
<label css={styles?.label} htmlFor={this._id}> | |||
<label css={styles?.label} id={this._id}> |
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.
htmlFor does not work for div elements and the textbox is a div element in CodeMirror so replaced with id
@@ -644,6 +645,15 @@ class SourceCodeEditor extends Component<SourceCodeEditorProps> { | |||
} | |||
} | |||
|
|||
assignAriaLabel = () => { | |||
if (this._containerRef) { | |||
const editorDiv = this._containerRef.querySelector('[role="textbox"]') |
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.
because the CodeMirror does not provide any way to reach this element, I had to find it like this
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.
An alternative way to find textbox is to go through child elements of the containerRef
if it is an element but this is good as well.
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.
nice work :)
Closes: INSTUI-4289
ISSUE: SourceCodeEditor label is not linked to the input field pragmatically. Therefore screenreader does not read the label when tabbed into the input field
TEST PLAN: