Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

make <Label> element focus & select at end to match native label behavior#63568

Merged
sqs merged 1 commit into
mainfrom
sqs/label-aria-native
Jul 1, 2024
Merged

make <Label> element focus & select at end to match native label behavior#63568
sqs merged 1 commit into
mainfrom
sqs/label-aria-native

Conversation

@sqs

@sqs sqs commented Jul 1, 2024

Copy link
Copy Markdown
Member

When our custom <Label> element is labelling a contenteditable element (like a CodeMirror editor), it previously just called element.focus(). This focused the element but put the cursor at the start. The native and expected behavior of <label for="..."> is to focus and put the cursor at the end.

Also fix an issue where this code path would be followed even if the label had no ID, which could result in it erroneously selecting an element with an empty aria-labelledby attribute.

Test plan

In the create/update saved search form, click on the label and ensure it focuses at the end of the CodeMirror component.

…havior

When our custom `<Label>` element is labelling a contenteditable element (like a CodeMirror editor), it previously just called `element.focus()`. This focused the element but put the cursor at the start. The native and expected behavior of `<label for="...">` is to focus and put the cursor at the end.

Also fix an issue where this code path would be followed even if the label had no ID, which could result in it erroneously selecting an element with an empty `aria-labelledby` attribute.
@sqs sqs requested a review from a team July 1, 2024 07:46
@cla-bot cla-bot Bot added the cla-signed label Jul 1, 2024
@sqs sqs merged commit a0c4f2f into main Jul 1, 2024
@sqs sqs deleted the sqs/label-aria-native branch July 1, 2024 15:41
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants