Skip to content

Firewall rules: disallow submitting empty target or host #2547

@david-crespo

Description

@david-crespo

This is moved around a bit in #2540 but the problem is the same: the if (!type || !value) return is doing what it's supposed to do, but the form still resets on empty submit. Not sure why.

const submitHost = hostForm.handleSubmit(({ type, value }) => {
// ignore click if empty or a duplicate
// TODO: show error instead of ignoring click
if (!type || !value) return
if (hosts.value.some((t) => t.value === value && t.type === type)) return
hosts.onChange([...hosts.value, { type, value }])
hostForm.reset(targetAndHostDefaultValues)
})

2024-11-12-empty-target.mp4

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions