dev/core#2919 Hidden submit buttons are confussing for keyboard users
authorBradley Taylor <hello@brad-taylor.co.uk>
Mon, 18 Oct 2021 17:14:19 +0000 (18:14 +0100)
committerBradley Taylor <hello@brad-taylor.co.uk>
Mon, 18 Oct 2021 17:14:19 +0000 (18:14 +0100)
Adds tabindex=-1 to hidden buttons, as hidden items should not be focussable.
As the elements are not focussable and repeated in the modal footer, aria-hidden is also applied

js/crm.ajax.js

index 609e1074a16dd56d345226eb6d63928325206d0b..39f7c85ef9aa29d3c196f69d2c9094bd90aafcb3 100644 (file)
           var $el = $(this),
             label = $el.is('input') ? $el.attr('value') : $el.text(),
             identifier = $el.attr('name') || $el.attr('href');
+          $el.attr('tabindex', '-1');
           if (!identifier || identifier === '#' || $.inArray(identifier, added) < 0) {
             var $icon = $el.find('.icon, .crm-i'),
               button = {'data-identifier': identifier, text: label, click: function() {
             added.push(identifier);
           }
           // display:none causes the form to not submit when pressing "enter"
-          $el.parents(buttonContainers).css({height: 0, padding: 0, margin: 0, overflow: 'hidden'});
+          $el.parents(buttonContainers).css({height: 0, padding: 0, margin: 0, overflow: 'hidden'}).attr('aria-hidden', 'true');
         });
         $el.dialog('option', 'buttons', buttons);
       }