-
Improvement
-
Resolution: Won't Do
-
Minor
-
None
-
2.6.1
-
MOODLE_26_STABLE
This comes from MDL-33653 and https://moodle.org/mod/forum/discuss.php?d=255651#p1109004
To see the problem, edit an existing Multiple choice question, put keyboard focus in the Question name field and press enter. The form reloads, because the form gets submitted as if the 'Add blanks for three more choices' button was pressed.
And, now I think about it some more, I remember that what happens on a form with multiple buttons when you press enter is not well defined. I think the behaviour is:
- IE and Chrome always behave as if the first button in the form was pressed.
- Firefox behaves as if the next button in the form, after the one where keyboard focus was pressed.
To get consistent behaviour (which woudl be a small but useful usability improvement) I think we need to add a bit of JavaScript that handles Key press: Enter exactly how we want. Specifically:
- New form class method $this->set_defualt_button($name); so that a given form can specify exactly what it wants.
- Heursitic for when this is not called:
- If add_action_buttons is used, then make the first button it adds the default
- Otherwise make the first button in the form, which is no a 'registerNoSubmitButton', the one.
- JavaScript code that intercepts keypress:enter, and make it click the given button, rather that submitting the form which picks a button at random as described above.
I think this is a worthwhile usability improvement, so I will file it in the tracker.