Skip to content

[lexical-link] Feature: Tell screen reader users when typing turns text into a link - #9071

Merged
etrepum merged 1 commit into
meta:mainfrom
Electro-Jam-Instruments:a11y-link-announce
Aug 21, 2026
Merged

etrepum merged 1 commit into
meta:mainfrom
Electro-Jam-Instruments:a11y-link-announce

Conversation

@Electro-Jam

Copy link
Copy Markdown
Contributor

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.

…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.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 16, 2026
@vercel

vercel Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lexical Ready Ready Preview Aug 16, 2026 5:09pm
lexical-playground Ready Ready Preview Aug 16, 2026 5:09pm

Request Review

@etrepum
etrepum added this pull request to the merge queue Aug 21, 2026
Merged via the queue into meta:main with commit 4bd462c Aug 21, 2026
48 checks passed
@etrepum etrepum mentioned this pull request Aug 31, 2026

This branch was successfully deployed

2 active deployments
Preview – lexical — 07f4509b Deployed Aug 16, 2026 by vercel[bot]
Preview – lexical-playground — 07f4509b Deployed Aug 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. extended-tests Run extended e2e tests on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants