Re: [w3c/webcomponents] Mechanism for setting the tabindex focus flag without sprouting tabindex attribute? (#762)

I'd like to continue the discussion about programmatic focus, just to make sure we aren't missing any critical functionality by excluding it.

I'd be interested to hear from @JanMiksovsky or any other web component developers whether the use cases I listed in https://github.com/w3c/webcomponents/issues/762#issuecomment-692416176 are the full range of what `tabindex=-1` is used for in practice.

For (1) above, perhaps a worked example might help with intuition.

Say you're developing a [date picker widget](https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/datepicker-dialog.html). When the date grid dialog is open, you'd want to be able to programmatically move focus/selection among the days of the month shown, but only have the pre-selected month appear in the focus order.

![Screen shot of the ARIA practices calendar widget example linked above, with the date picker dialog open](https://user-images.githubusercontent.com/95208/95288287-aa0bcb80-08b3-11eb-81fc-eda6e596a100.png)

In this screenshot, the user had previously used the arrow keys to move focus/pre-selection to '1', and then used the tab key to move focus to the "previous month" button. 

If the user uses the tab key to move the focus back to the calendar grid, the '1' cell will be focused again. If the user clicks on any of the other days, or uses the arrow keys to select an adjacent day, that day will be focused and pre-selected (the selection not being committed until the user activates the 'Ok' button).

I am interested in whether developers would tend to:
- use `tabindex` to make the day elements programmatically/sequentially focusable as necessary, or 
- coordinate to make the "next" day element (e.g. "2", if the user had focused "1" and pressed the right arrow key) focusable "just in time", by giving the coordinating script access to each day's `ElementInternals`, or
- miss a potential mechanism to have the day elements be made programmatically focusable via `ElementInternals`, so that you could call `focus()` without having to have access to the `ElementInternals` or use `tabindex` to make the element focusable first.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/762#issuecomment-704692124

Received on Wednesday, 7 October 2020 04:59:29 UTC