Skip to content

Enter in firewall rule targets/hosts listbox submits full form #2784

Open
@david-crespo

Description

@david-crespo

In #2540 we made it so you don't accidentally submit the entire firewall rule form when you press enter in the target combobox with the intention of submitting that "subform" (a made up concept that haunts me every day). While messing with a combobox in a modal for #2775 it occurred to me that we had done no such treatment for the type listbox, and I quickly confirmed that when you have that field focused and press enter, it submits the entire form. Fortunately this is not very urgent because unlike with the combobox, users are very unlikely to press enter with the type listbox focused, and it's not the end of the world if they do, it's just moderately annoying.

We could of course do a similar hack in listbox and eat enter keypresses when an alternate onEnter is present. There might be a better way where we catch the event before it gets out of the subform. See #2557 (comment) and #2610 too.

onKeyDown={(e) => {
// Prevent form submission when the user presses Enter inside a combobox.
// The combobox component already handles Enter keypresses to select items,
// so we only preventDefault when the combobox is closed.
if (e.key === 'Enter' && !open) {
e.preventDefault()
onEnter?.(e)
}
}}

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions