Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5787

aria-hidden elements do not contain focusable elements

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 10.1.0
    • None
    • None
    • Security Level: Jimmy

      Steps to Reproduce

      1. Run a Listbox with A11y module
      2. Click any Listitem

      Current Result

      Console log with an error:

      Blocked aria-hidden on a <div> element because the element that just received focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden. 
      <div id="n7JG1-a" style="top: 256px; left: 0px;" class="z-focus-a" tabindex="-1" aria-labelledby="n7JG1" aria-label="focus" aria-hidden="true"></div> 

      Expected Result

      No error or warning on the console log.

      Debug Information

      The aria-hidden="true" attribute is set with focusable element will cause Chrome to show warning in the console. Such as a Div element with tabindex="" or Input element.

       

      Workaround

      add the following script to prevent this warning.

      document.body.addEventListener('focusin', function(event) {
          // Checking if the target element is focusable and has `aria-hidden`
          var parent = event.target;
          while (parent && parent != document.body) {
            if (parent.getAttribute('aria-hidden') === "true") {
                parent.setAttribute('aria-hidden', 'false');
            }
            parent = parent.parentNode;
          }
      });
      document.body.addEventListener('focusout', function(event) {
          // Resetting aria-hidden to true when element loses focus
          var parent = event.target;
          while (parent && parent != document.body) {
            if (parent.getAttribute('aria-hidden') === "false") {
                parent.setAttribute('aria-hidden', 'true');
            }
            parent = parent.parentNode;
          }
      }); 

            jumperchen jumperchen
            jumperchen jumperchen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: