Skip to content

Commit e3a7710

Browse files
committed
bind icmp type input value to form value
1 parent 6145e42 commit e3a7710

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

app/forms/firewall-rules-common.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ const ProtocolFilters = ({ control }: { control: Control<FirewallRuleValues> })
468468
description="Leave blank to match any type"
469469
placeholder=""
470470
allowArbitraryValues
471+
onInputChange={(value) => protocolForm.setValue('icmpType', value)}
471472
items={icmpTypeItems}
472473
validate={(value) => {
473474
const result = parseIcmpType(value)

test/e2e/firewall-rules.e2e.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,19 @@ test('arbitrary values combobox', async ({ page }) => {
652652

653653
// same options show up after blur (there was a bug around this)
654654
await expectOptions(page, ['db1', 'db2', 'Custom: d'])
655+
656+
// make sure typing in ICMP filter input actually updates the underlying value,
657+
// triggering a validation error for bad input. without onInputChange binding
658+
// the input value to the form value, this does not trigger an error because
659+
// the form thinks the input is empyt.
660+
await selectOption(page, 'Protocol filters', 'ICMP')
661+
await page.getByRole('combobox', { name: 'ICMP type' }).pressSequentially('abc')
662+
const error = page
663+
.getByRole('dialog')
664+
.getByText('ICMP type must be a number between 0 and 255')
665+
await expect(error).toBeHidden()
666+
await page.getByRole('button', { name: 'Add protocol filter' }).click()
667+
await expect(error).toBeVisible()
655668
})
656669

657670
test("esc in combobox doesn't close form", async ({ page }) => {

0 commit comments

Comments
 (0)