Set focus in modals to first input field by default

After invoking a shortcut, some dialogs required pressing `Tab`
or using the mouse until focus was moved to the primary input field.

By moving the focus automatically, users can start typing right away.
This is particularly useful in conjunction with the `Return` key for
confirming the dialog.

Test Plan:
- Press `X` to open "Export" dialog:
  "Name" field has focus.
- Press `Shift+O` to open "Load track as route":
  "Trackfile" is focussed, file dialog opens with `Space`.
- Check "Load no-go area" dialog.
- Check "POI name" dialog.
This commit is contained in:
Henrik Fehlauer 2021-03-31 18:00:00 +00:00
parent eb8a7a9d36
commit 13794c3df3

View file

@ -457,6 +457,10 @@
); );
BR.WhatsNew.init(); BR.WhatsNew.init();
$('.modal').on('shown.bs.modal', function (e) {
$('input:visible:enabled:first', e.target).focus();
});
} }
i18next.on('languageChanged', function (detectedLanguage) { i18next.on('languageChanged', function (detectedLanguage) {