Skip to content

Can't attach label to editor #751

Open

Description

@NiklasEi

In the following snippet, I cannot click on the label and get the cursor to jump into the editor:

import React, { useState } from "react";
import CodeMirror from "@uiw/react-codemirror";
import { javascript } from "@codemirror/lang-javascript";

export default function App() {
  const onChange = React.useCallback((value, viewUpdate) => {
    console.log("value:", value);
  }, []);
  return (
    <div>
      <label for="test">Test</label>
      <CodeMirror
        id="test"
        value="console.log('hello world!');"
        height="200px"
        theme="dark"
        extensions={[javascript({ jsx: true })]}
        onChange={onChange}
      />
    </div>
  );
}

Activity

  1. mishs commented on Sep 25, 2026

    @mishs

    Hi maintainers, I reviewed #751 and would be interested in contributing a focused accessibility fix if external contributions are welcome.

    My proposed scope is to ensure a visible label can be reliably associated with the actual focusable editor,
    so activating the label focuses the editor as expected.
    I would preserve the existing component API,
    refs and keyboard behaviour where possible and add regression tests for the label/focus relationship.

    Before implementing, I would confirm whether you prefer forwarding id to the focus target or exposing an explicit accessible-labelling prop.
    Is the issue still available, and which direction would be acceptable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions