Skip to content

Commit

Permalink
Fix irritating Enter key behaviour in container creation dialog
Browse files Browse the repository at this point in the history
Pressing "Enter" in the dialog on any active form element (such as the
search input or the checkboxes) previously bubbled up to the Form, which
then activated the first popover help. This is unexpected and very
irritating especially when using the search input.

Just ignore the Enter key to fix that, similar to what the image search
modal already does.

See cockpit-project#1821 (comment)
  • Loading branch information
martinpitt committed Sep 26, 2024
1 parent ea8bac0 commit e34f08e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ImageRunModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ export class ImageRunModal extends React.Component {
);

const defaultBody = (
<Form>
<Form onKeyDown={e => e.key === 'Enter' && e.preventDefault()}>
{this.state.dialogError && <ErrorNotification errorMessage={this.state.dialogError} errorDetail={this.state.dialogErrorDetail} />}
<FormGroup id="image-name-group" fieldId='run-image-dialog-name' label={_("Name")} className="ct-m-horizontal">
<TextInput id='run-image-dialog-name'
Expand Down
9 changes: 8 additions & 1 deletion test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -1738,9 +1738,16 @@ class TestApplication(testlib.MachineCase):

# Local registry
b.click('button.pf-v5-c-toggle-group__button:contains("localhost:5000")')
b.set_input_text("#create-image-image-select-typeahead", "my-busybox")
b.set_input_text("#create-image-image-select-typeahead", "my-busybox", blur=False)
b.wait_text("button.pf-v5-c-select__menu-item:not(.pf-m-disabled)", "localhost:5000/my-busybox")

# pressing Enter does not disturb the dialog or open popup help
b.wait_val("#create-image-image-select-typeahead", "my-busybox")
b.key("Enter")
time.sleep(0.3)
self.assertFalse(b.is_present(".pf-v5-c-popover"))
b.wait_val("#create-image-image-select-typeahead", "my-busybox")

# Select image
b.click('button.pf-v5-c-select__menu-item:contains("localhost:5000/my-busybox")')

Expand Down

0 comments on commit e34f08e

Please sign in to comment.