Closed Bug 69825 Opened 24 years ago Closed 24 years ago

Enter key handled inconsistently on forms

Categories

(Core :: DOM: UI Events & Focus Handling, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 54035

People

(Reporter: jsp, Assigned: joki)

References

Details

(Keywords: testcase)

Attachments

(1 file)

From Bugzilla Helper: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; 0.8) Gecko/20010215 BuildID: 2001021508 Forms that have a single input are submitted when the Enter key is pressed, even if preventDefault() and stopPropagation() are called in a keypress event handler. Forms that have multiple inputs are not submitted when the Enter key is pressed. Behavior should be consistent and subject to control by event handlers. Reproducible: Always Steps to Reproduce: 1) Load the attached test case. 2) Put the focus in the first input, press Enter, and observe the response. 3) Repeat 2) for each of the remaining inputs. Actual Results: Forms with a single input are submitted, even if a keypress event handler attempts to prevent it with stopPropagation() and preventDefault(). Expected Results: Consistent behavior, controllable by event handlers, regardless of the number of inputs. I would not expect Enter to submit ANY of the forms in the test case, but if it's desirable to have it do so, I'd expect it to behave the same on forms with multiple inputs, and to respect preventDefault() and stopPropagation() in keypress event handlers. Also manifests in M 0.8 on Macintosh. I'm guessing at the correct component. Form Submission or HTML Form Controls are other obvious possibilities, but this seemed like the best fit. If it's decided that letting Enter submit is desirable, this is probably two bugs: one to get Enter behaving consistently, one to get the event handler's efforts respected. Authors can work around this by setting up a form submit event handler that always returns false. You'll need to call the form.submit() method yourself when you want the form submitted; the good news is that the submit event handler doesn't interfere with this.
Attached file Test case. (deleted) —
See also bgu 22526, "Enter in text input submits form iff there is exactly one text input".
Similar but not identical. Matthew Thomas' proposed spec would address at least part of my problem, since he proposes activating whatever submit control is appropriate given his rules, and my page has no submit control. Presumably, in the absence of such a control, the form would not be submitted. If Matthew's spec is implemented in such a way that Enter keypress events on the input in a single-input form can be caught, my concerns would be completely addressed. (I don't actually much care what the default behavior is, as long as I can catch the event and override that behavior.)
Keywords: testcase
Moving to UI/design & marking NEW.
Assignee: joki → mpt
Status: UNCONFIRMED → NEW
Component: Event Handling → User Interface Design
Ever confirmed: true
QA Contact: gerardok → zach
This ain't a UI design problem, it's an Event Handling problem (or possibly an HTML Form Controls problem).
Assignee: mpt → joki
Component: User Interface Design → Event Handling
Depends on: 22526
QA Contact: zach → gerardok
The fact that you can't cancel the submission with the enter key is a dupe of bug 54035. A discussion of the second part about whether or not we should submit forms with multiple text fields on Enter is covered in bug 22526. *** This bug has been marked as a duplicate of 54035 ***
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
QA contact updated
QA Contact: gerardok → madhur
QA Contact: madhur → rakeshmishra
QA Contact: rakeshmishra → trix
Component: Event Handling → User events and focus handling
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: