Skosmos icon indicating copy to clipboard operation
Skosmos copied to clipboard

Tabindex = -1 steals focus

Open kouralex opened this issue 4 years ago • 3 comments

It seems like clicking on any non-clickable element on the #maincontent element shifts the tab focus to the very beginning of the #maincontent element regardless of the position of clicked element (e.g., span). The culprit seems to be the tabindex setting here https://github.com/NatLibFi/Skosmos/blob/299ee49ab72d0ce7d07229e9f736e58a0000fe61/view/light.twig#L170 which was added in order to improve the accessibility of the software.

This is not intended nor expected behavior as, for example, clicking on a widget + tab does not keep the focus in the clicked element (although invisibly so) as it would in normal website browsing.

kouralex avatar Oct 13 '20 10:10 kouralex

This seems to be in effect also after page load; previously the focus was (and should be) in the search field.

joelit avatar Nov 11 '20 11:11 joelit

the focus was (and should be) in the search field

I disagree with the "should be". The auto-focus on the search field was intentionally disabled in PR #1050 (commit 9d58f666d7a3e601da71e2ea710a0fa2ff4c7088) because it's bad practice to autofocus on a field on page load, unless the main purpose of the page is to fill in a form (e.g. login form or Google front page).

See e.g. https://stackoverflow.com/questions/2180645/is-automatically-assigning-focus-bad-for-accessibility

osma avatar Nov 11 '20 12:11 osma

Good point, I hadn't considered that - but now that you mention it, it's true that the initial focus of the page wholly depends on the intended use cases. As long as searching for a new concept is not the main thing a user would do, there's no automatic reason for the focus to be on the search field. In the case of a concept page, it is not even that clear to all of the users that there is going to be a search field.

joelit avatar Nov 11 '20 14:11 joelit