Repository navigation
[lexical-link] Feature: Tell screen reader users when typing turns text into a link - #9071
Merged
Merged
Conversation
…xt into a link ## Description ### Why Type a web address into the editor and it becomes a link on its own, partway through typing it, at the moment the address first matches. There is no shortcut or button behind it: typing the next character of the address is what turns the text into a link. The characters themselves do not change — the same text is simply a link now. A sighted user sees it happen: the text turns blue and underlines itself. A screen reader announces nothing at all. The user finishes the address and carries on, with no idea their document now contains a link. Removing one is equally quiet. Backspace until what is left no longer looks like a web address and the link disappears, with nothing said. Delete a line that had addresses in it and nothing says the links went with it. `@lexical/a11y` already announces undo, redo and editable/read-only. This adds the same for links the editor makes on its own. ### What Announces automatic links through the editor's aria live region: - typing an address turns it into a link → **"Link"** - backspacing until it no longer looks like an address → **"Link removed"** - deleting a selection that spans several → **"3 links removed"** - pasting text holding several addresses → **"2 links"** `AutoLinkAnnounceExtension` lives in `@lexical/link` beside `AutoLinkNode`, and `AutoLinkExtension` depends on it, so an editor with automatic links announces them without anyone opting in. `@lexical/link` gains a dependency on `@lexical/a11y`; the dependency does not run the other way. ### Shape `defineExtension` with `namedSignals` and `safeCast`, a config of message strings plus a runtime `disabled` signal, gated from an `effect` so a disabled announcer registers no listener at all. `%s` is substituted with the count, so the strings stay translatable. A creation paired with a destruction in the same update is not announced. Every keystroke that extends an address rebuilds the link — the old node destroyed and a new one created at once — so announcing every creation would say "Link" at `www.example.c`, again at `o`, and again at `m`. Only a creation on its own is a link that was not there a moment ago. ### What this does not announce **Anything after the link appears.** Once the address has matched, everything else typed is silent, including the rest of the address itself. The link is announced once, when it appears, and not again while it grows. **Where the link points.** The browser puts the address in the accessibility tree, where a screen reader can read it on request, and the user has just typed it in any case. ### Notes on scope **Links made from the toolbar are not announced.** Ctrl+K and the unlink button are things the user chose to do, through a dialog they filled in themselves, and the outcome was known before confirming it. Nothing was done to them that they did not ask for, which is the case this change covers. That case would belong with `LinkExtension` rather than here. **Bulk removals say how many went.** Deleting a selection takes every link inside it in one edit, so this announces "3 links removed" rather than "Link removed", which is what a single link and a dozen links would otherwise sound like. Announcing once per link would mean three announcements for one keystroke, and the live region only holds the last, so the count would be lost. It costs two more config strings, `createdMany` and `destroyedMany`, in a message that most of the time carries no number at all. ## Test plan Nine cases in `packages/lexical-link/src/__tests__/unit/AutoLinkAnnounceExtension.test.ts`, including the silence cases — nothing otherwise prevents an announcement on every keystroke, so that regression would be invisible. ### Before With `AutoLinkAnnounceExtension` removed from `AutoLinkExtension.dependencies`: ``` $ npx vitest run --project unit packages/lexical-link/src/__tests__/unit/AutoLinkAnnounceExtension.test.ts × announces a typed address becoming a link 205ms × announces a link being removed 19ms × says how many links went when a selection takes several 15ms × says how many links arrived when several appear at once 15ms × says nothing when disabled 8ms Test Files 1 failed (1) Tests 5 failed | 4 passed (9) ``` ### After ``` $ npx vitest run --project unit packages/lexical-link/src/__tests__/unit/AutoLinkAnnounceExtension.test.ts Test Files 1 passed (1) Tests 9 passed (9) ``` The whole unit suite: ``` $ npx vitest run --project unit Test Files 251 passed (252) Tests 4220 passed | 1 skipped (4222) ``` `FastPathCrossParent.test.ts` timed out at the 5s limit during that run and passes on its own; it is a fuzz test over 100 seeds and the machine was loaded. End to end against the dev server, in both editor modes. `AutoLinks.spec.mjs` drives the node this listener watches, and `Markdown.spec.mjs` covers undo: ``` $ E2E_BROWSER=chromium E2E_EDITOR_MODE=rich-text npx playwright test \ --project=chromium \ packages/lexical-playground/__tests__/e2e/Markdown.spec.mjs \ packages/lexical-playground/__tests__/e2e/AutoLinks.spec.mjs 116 passed (1.8m) $ E2E_BROWSER=chromium E2E_EDITOR_MODE=plain-text npx playwright test --project=chromium 711 skipped 136 passed (6.0m) ``` Not run on this machine: firefox and webkit, macOS, and anything needing a production build.
Electro-Jam
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 16, 2026 17:08
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
approved these changes
Aug 21, 2026
Merged
This was referenced Sep 9, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Why
Type a web address into the editor and it becomes a link on its own, partway
through typing it, at the moment the address first matches. There is no
shortcut or button behind it: typing the next character of the address is what
turns the text into a link. The characters themselves do not change — the same
text is simply a link now.
A sighted user sees it happen: the text turns blue and underlines itself. A
screen reader announces nothing at all. The user finishes the address and
carries on, with no idea their document now contains a link.
Removing one is equally quiet. Backspace until what is left no longer looks
like a web address and the link disappears, with nothing said. Delete a line
that had addresses in it and nothing says the links went with it.
@lexical/a11yalready announces undo, redo and editable/read-only. This addsthe same for links the editor makes on its own.
What
Announces automatic links through the editor's aria live region:
AutoLinkAnnounceExtensionlives in@lexical/linkbesideAutoLinkNode, andAutoLinkExtensiondepends on it, so an editor with automatic links announcesthem without anyone opting in.
@lexical/linkgains a dependency on@lexical/a11y; the dependency does not run the other way.Shape
defineExtensionwithnamedSignalsandsafeCast, a config of messagestrings plus a runtime
disabledsignal, gated from aneffectso a disabledannouncer registers no listener at all.
%sis substituted with the count, sothe strings stay translatable.
A creation paired with a destruction in the same update is not announced. Every
keystroke that extends an address rebuilds the link — the old node destroyed and
a new one created at once — so announcing every creation would say "Link" at
www.example.c, again ato, and again atm. Only a creation on its own is alink that was not there a moment ago.
What this does not announce
Anything after the link appears. Once the address has matched, everything
else typed is silent, including the rest of the address itself. The link is
announced once, when it appears, and not again while it grows.
Where the link points. The browser puts the address in the accessibility
tree, where a screen reader can read it on request, and the user has just typed
it in any case.
Notes on scope
Links made from the toolbar are not announced. Ctrl+K and the unlink button
are things the user chose to do, through a dialog they filled in themselves, and
the outcome was known before confirming it. Nothing was done to them that they
did not ask for, which is the case this change covers. That case would belong
with
LinkExtensionrather than here.Bulk removals say how many went. Deleting a selection takes every link
inside it in one edit, so this announces "3 links removed" rather than "Link
removed", which is what a single link and a dozen links would otherwise sound
like. Announcing once per link would mean three announcements for one keystroke,
and the live region only holds the last, so the count would be lost. It costs
two more config strings,
createdManyanddestroyedMany, in a message thatmost of the time carries no number at all.
Test plan
Nine cases in
packages/lexical-link/src/__tests__/unit/AutoLinkAnnounceExtension.test.ts,including the silence cases — nothing otherwise prevents an announcement on
every keystroke, so that regression would be invisible.
Before
With
AutoLinkAnnounceExtensionremoved fromAutoLinkExtension.dependencies:After
The whole unit suite:
FastPathCrossParent.test.tstimed out at the 5s limit during that run andpasses on its own; it is a fuzz test over 100 seeds and the machine was loaded.
End to end against the dev server, in both editor modes.
AutoLinks.spec.mjsdrives the node this listener watches, and
Markdown.spec.mjscovers undo:Not run on this machine: firefox and webkit, macOS, and anything needing a
production build.