Skip to content

Commit 3bf5665

Browse files
committed
try to fix firewall rule test flake
1 parent 867e4da commit 3bf5665

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

app/forms/firewall-rules-common.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,12 @@ const ProtocolFilters = ({ control }: { control: Control<FirewallRuleValues> })
494494
placeholder=""
495495
validate={icmpCodeValidation}
496496
transform={normalizeDashes}
497+
onKeyDown={(e) => {
498+
if (e.key === KEYS.enter) {
499+
e.preventDefault() // prevent full form submission
500+
submitProtocol(e)
501+
}
502+
}}
497503
/>
498504
)}
499505
</>

app/ui/lib/Combobox.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,12 @@ export const Combobox = ({
213213
onInputChange?.(value)
214214
}}
215215
onKeyDown={(e) => {
216-
// If the caller is using onEnter to override enter behavior, preventDefault
217-
// in order to prevent the containing form from being submitted too. We don't
218-
// need to do this when the combobox is open because that enter keypress is
219-
// already handled internally (selects the highlighted item). So we only do
220-
// this when the combobox is closed.
221-
if (e.key === 'Enter' && onEnter && !open) {
216+
// When the combobox is open, Enter is handled internally by Headless UI
217+
// (selects the highlighted item). When closed, we need to prevent the
218+
// default behavior to avoid submitting the containing form.
219+
if (e.key === 'Enter' && !open) {
222220
e.preventDefault()
223-
onEnter(e)
221+
onEnter?.(e)
224222
}
225223
}}
226224
placeholder={placeholder}

test/e2e/firewall-rules.e2e.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,6 @@ test('can update firewall rule', async ({ page }) => {
456456
await selectOption(page, 'Protocol filters', 'ICMP')
457457
await page.getByRole('combobox', { name: 'ICMP Type' }).fill('3')
458458
await page.getByRole('combobox', { name: 'ICMP Type' }).press('Enter')
459-
460-
// give FF time to process the above enter before moving to the next field
461-
await sleep(300)
462-
463459
await page.getByRole('textbox', { name: 'ICMP Code' }).fill('0')
464460
await page.getByRole('button', { name: 'Add protocol' }).click()
465461

0 commit comments

Comments
 (0)