Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: fill() on a paragraph inside a contenteditable body in an iframe resolves but inserts nothing

Aperta
#43,483 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@yury-s ci sta già lavorando.

Dal 16/10/2026.

  • #43487 di @yury-s — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
18/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
typescript
Ambito
testing

Direzione di ricerca

Start by reproducing the report with the snippet in the issue, using Chrome in headless mode, and note that fill() succeeds while the <p> text never changes. The issue points to focus handling: fill() should focus the nearest [contenteditable] ancestor when the target is not focusable, as it does for inputs. Check the already-open pull request #43487 first, since someone is working on this. Done means the reproduction passes and the <p> inside an iframe's <body contenteditable> is filled.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

1.63.0

Steps to reproduce
import { test, expect } from '@playwright/test';

test('fill a paragraph of an editor in an iframe', async ({ page }) => {
  await page.setContent(`<iframe srcdoc="<body contenteditable><p id=p>old</p></body>"></iframe>`);
  const frame = page.frames()[1];
  await frame.locator('#p').waitFor();
  await frame.locator('#p').fill('new');   // resolves without error
  await expect(frame.locator('#p')).toHaveText('new');   // fails: still "old"
});
Expected behavior

fill() replaces the paragraph's text with new, or throws.

Actual behavior

fill() resolves, and nothing is inserted anywhere: the paragraph keeps old.

The target is editable (isContentEditable is inherited from the <body contenteditable>), but it is not focusable itself, and its frame's document does not have focus, so the inserted text goes to whichever document has focus. Observations:

  • frame.locator('body').fill('new') works (the editing host is focused).
  • Focusing the editing host first makes the paragraph fill work: await frame.locator('#p').evaluate(el => el.closest('[contenteditable]').focus()).
  • The same happens in the top page when another frame has focus: a <p> inside <div contenteditable> is not filled while an iframe's document is focused.
  • Seen on a real editor: the TinyMCE demo at https://the-internet.herokuapp.com/iframe (its <p> inside the editor frame).

Perhaps fill() could focus the element's editing host (the nearest [contenteditable] ancestor) when the target itself is not focusable, as it focuses inputs. Possibly related, but a different cause (an editor's focus handler): #39492.

Additional context

We work around it in a tool built on Playwright by focusing the nearest editing host before fill().

Environment
  • Playwright (playwright-core) 1.63.0, Node.js 24.21.0
  • Google Chrome 155.0.8059.80 (channel: 'chrome'), headless
  • macOS 27 (arm64)
Lingua principale
TypeScript
Stelle
97.4k
Fork
6.6k
Merge medio
18h 15m
PR unite (30g)
318

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.