scottohara / loot

An implementation of some of the core MS Money features in Ruby on Rails
MIT License
4 stars 3 forks source link

Default action for delete modal should be the delete button #42

Closed scottohara closed 9 years ago

scottohara commented 10 years ago

Hitting enter in the delete modal doesn't trigger the delete action.

scottohara commented 9 years ago

This is actually related to #34.

Both the edit and delete modals use <button type="submit"> to ensure that the enter key triggers a form submission. But this only works if the form (ie. if any of the fields in the form) has focus.

In the case of a delete modal, there are no form inputs; so the form never really has focus.

Due to the autofocus limitations described #34, the problem can also be seen in edit modals opened subsequently (where no field initially gets focus), so hitting the enter key does nothing there either.

The fix here is to add autofocus to the delete buttons (and to the buttons in the og-modal-alert / og-modal-confirm directives). Once a fix for the autofocus problems is available in ui-bootstrap; this will then automatically apply to these modals too.