Skip to content

Commit 595b391

Browse files
authored
Fix Firefox flake in Subform browser spec (#3431)
Same as #3398 but for the Subform test. 🤖 In Firefox, Playwright fill inserts text as an IME composition, and Headless UI ignores Enter for two animation frames after compositionend. The Enter that followed often landed inside that window and submitted the form. Type with real key presses instead.
1 parent 3a0b5a9 commit 595b391

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

‎app/components/form/Subform.browser.spec.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ afterEach(() => {
2626

2727
const items = toComboboxItems([{ name: 'disk-3' }, { name: 'disk-4' }])
2828

29-
// Filling alone doesn't reliably leave the first option highlighted (Firefox
30-
// CI pressed Enter with nothing active), so open the list and Home to it
31-
// explicitly, like Combobox.browser.spec.tsx does
29+
// Type with real key presses rather than `fill`. In Firefox, Playwright's fill
30+
// inserts the text as an IME composition, and Headless UI ignores Enter until
31+
// two animation frames after compositionend (so the Enter that commits an IME
32+
// composition doesn't also select an option). The following Enter often comes
33+
// sooner than that, falls through, and submits the form.
3234
async function highlightFirstOption(screen: RenderResult, label: string) {
3335
const combobox = screen.getByRole('combobox', { name: label })
34-
await combobox.fill('disk')
35-
await commands.pressComboboxKey(label, 'ArrowDown')
36+
await userEvent.type(combobox, 'disk')
3637
const option = screen.getByRole('option', { name: 'disk-3' })
3738
await expect.element(option).toBeVisible()
38-
await commands.pressComboboxKey(label, 'Home')
3939
await expect
4040
.element(combobox)
4141
.toHaveAttribute('aria-activedescendant', option.element().id)

‎app/ui/lib/Combobox.browser.spec.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ test('Enter commits the highlighted option instead of the arbitrary query', asyn
179179
)
180180
const combobox = screen.getByRole('combobox', { name: 'Disk name' })
181181

182-
await combobox.fill('mock')
182+
// Type rather than fill: in Firefox, fill is an IME composition, and Headless
183+
// UI ignores Enter for two frames after one ends
184+
await userEvent.type(combobox, 'mock')
183185
await commands.pressComboboxKey('Disk name', 'ArrowDown')
184186
const listedOption = screen.getByRole('option', { name: 'mock-vpc' })
185187
await expect.element(listedOption).toBeVisible()

0 commit comments

Comments
 (0)