sebnitu / vrembem

A CSS component library based on the BEM methodology.

Home Page:https://vrembem.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

getFocusable should focus first element if initFocus is undefined

sebnitu opened this issue · comments

Problem

Because of how the getFocusable() tests focusable elements, if an initial focus element is not returned, the element this method is called on will keep focus on the last element tested. This also causes the scroll reset to not work.

Possible Solution

  • If no initFocus element was returned, focus the first element after all element testing is finished.
  • Reverse the focusable elements array so that the last tested element would be the first focusable element in the target.
  • Add el.blur() after the element passes and is added to the array.