mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-23 10:40:58 -04:00
Tidy up JS code for focusing & associated html
Makes sure the tabindex we add for focusing is removed. Also removes the outer fieldset from the radios for new templates. We don't wrap form buttons in fieldsets anywhere else and it doesn't add any useful semantics to the form.
This commit is contained in:
@@ -19,10 +19,10 @@
|
||||
this.states = [
|
||||
{key: 'nothing-selected-buttons', $el: this.$form.find('#nothing_selected'), cancellable: false},
|
||||
{key: 'items-selected-buttons', $el: this.$form.find('#items_selected'), cancellable: false},
|
||||
{key: 'move-to-existing-folder', $el: this.$form.find('#move_to_folder_radios'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_folder_radios fieldset', true)},
|
||||
{key: 'move-to-existing-folder', $el: this.$form.find('#move_to_folder_radios'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_folder_radios legend', true)},
|
||||
{key: 'move-to-new-folder', $el: this.$form.find('#move_to_new_folder_form'), cancellable: true, setFocus: this.getFocusRoutine('#move_to_new_folder_name', false)},
|
||||
{key: 'add-new-folder', $el: this.$form.find('#add_new_folder_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_folder_name', false)},
|
||||
{key: 'add-new-template', $el: this.$form.find('#add_new_template_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_template_form fieldset', true)}
|
||||
{key: 'add-new-template', $el: this.$form.find('#add_new_template_form'), cancellable: true, setFocus: this.getFocusRoutine('#add_new_template_form legend', true)}
|
||||
];
|
||||
|
||||
// cancel/clear buttons only relevant if JS enabled, so
|
||||
@@ -47,9 +47,15 @@
|
||||
this.getFocusRoutine = function (selector, setTabindex) {
|
||||
return function () {
|
||||
let $el = $(selector);
|
||||
let removeTabindex = (e) => {
|
||||
$(e.target)
|
||||
.removeAttr('tabindex')
|
||||
.off('blur', removeTabindex);
|
||||
};
|
||||
|
||||
if (setTabindex) {
|
||||
$el.attr('tabindex', '-1');
|
||||
$el.on('blur', removeTabindex);
|
||||
}
|
||||
|
||||
$el.focus();
|
||||
|
||||
Reference in New Issue
Block a user