Bug 31413: Set focus for cursor to Selector when adding a new audio alert

This patch adds a step to the process of displaying the new audio alert
form so that focus will be set to the first field when the form has
finished appearing. The typical "focus" class only works on elements
which are present in the initial DOM when the page is displayed.

To test, apply the patch and go to Administration -> Audio alerts.

Click the "New alert" button. When the form appears cursor focus should
be on the "Selector" field.

Also test the edit process: When editing an existing alert there should
not be automatic cursor focus.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 7c8434553a)
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
Owen Leonard 2023-02-06 13:10:30 +00:00 committed by Matt Blenkinsop
parent 46725327bb
commit 5e593d098d

View file

@ -25,7 +25,9 @@ $( document ).ready(function() {
$("#newalert").on("click",function(e){
e.preventDefault();
$("#new-alert-form").show();
$("#new-alert-form").show( 0, function(){
$("#selector").focus();
});
$("#toolbar, #delete-alert-form").hide();
});