Re: [csswg-drafts] [css-nav-1] FocusTraversal API (#3944)

Thank you for the great input!
I guess the FocusTraversal API is proposed for the sequential navigation (navigation with Tab key), but there are some features which are also needed in the spatial navigation.

There are APIs in Spatial Navigation Spec that match with the part of your proposed API.

* [window.navigate(_dir_)](https://drafts.csswg.org/css-nav-1/#dom-window-navigate)
  * Move the focus to the next focusable element with the given direction
  * [_dir_](https://drafts.csswg.org/css-nav-1/#enumdef-spatialnavigationdirection) is `left`, `right`, `up` or `down`.
  * Matchs with FocusTraversal API : 
window.focusManager.forward(), window.focusManager.backward()

* [Element.spatialNavigationSearch(_option_)](https://drafts.csswg.org/css-nav-1/#dom-element-spatialnavigationsearch)
  * Returns the element which will gain the focus from the target element
  * With _option_ , the navigate direction([_dir_](https://drafts.csswg.org/css-nav-1/#enumdef-spatialnavigationdirection)) can be specified
  * Matches with FocusTraversal API
: window.focusManager.next(element), window.focusManager.previous(element)

* [Element.focusableAreas()](https://drafts.csswg.org/css-nav-1/#dom-element-focusableareas)
  * Finds focusable elements within the target element
  * Matches with
: window.focusManager.isFocusable()
    * This isn't the perfect match, but I add this those are related. Because `Element.focusableAreas()` needs isFocusable().

More about `isFocusable()`, there is a polyfill of the spec and the polyfill also has [`isFocusable()`](https://github.com/WICG/spatial-navigation/blob/master/polyfill/spatial-navigation-polyfill.js#L754) function.
When I implemented this function, I referenced the definition of [`focusable areas` in HTML Spec](https://html.spec.whatwg.org/multipage/interaction.html#focusable-area). 
But it was hard to simplify the implementation, so I also referenced [Focusable Elements - Browser Compatibility Table](https://allyjs.io/data-tables/focusable.html).
I'm open to considering this API as a standard API.

I've noticed that there are on-going discussions about the [clarifying the focusable](https://github.com/whatwg/html/issues/4464) and considering [overall focus in HTML spec](https://github.com/whatwg/html/issues/4607). (Oh, you have already joined the discussion!)
Maybe `isFocusable()` can also be related to this discussion.

I'm also interested in `window.focusManager.previouslyFocused` and `window.focusManager.history`,
because of those features - saving the track of the focus movement- are also in my list for future standard API proposal. : ) 



-- 
GitHub Notification of comment by jihyerish
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3944#issuecomment-494718858 using your GitHub account

Received on Wednesday, 22 May 2019 09:05:10 UTC