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.
- 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.
I think this is a worthwhile usability improvement, so I will file it in the tracker.