From 13794c3df36e3f7a2d3a1a3a9aa817347f3992d8 Mon Sep 17 00:00:00 2001 From: Henrik Fehlauer Date: Wed, 31 Mar 2021 18:00:00 +0000 Subject: [PATCH] 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. --- js/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/js/index.js b/js/index.js index 2ef465b..7444ac4 100644 --- a/js/index.js +++ b/js/index.js @@ -457,6 +457,10 @@ ); BR.WhatsNew.init(); + + $('.modal').on('shown.bs.modal', function (e) { + $('input:visible:enabled:first', e.target).focus(); + }); } i18next.on('languageChanged', function (detectedLanguage) {