Focus and tabIndex after items fetched
-
Hi there, we have stumbled on a couple of issues which I think were introduced with the latest release.
When new items are loaded, the first element in the list is run through the
moveFocus()
function that includes this snippetelement.setAttribute('tabIndex', '-1'); // Set tabIndex. element.style.outline = 'none'; // Set element outline. // Add slight delay for elements to settle into DOM. setTimeout(function () { element.focus({ preventScroll: true }); }, 25);
In my mind there are two issues with this
- Taking the first item out of the tabindex list means an accessible user can no longer traverse up and down through the items without being forced to skip the first-loaded item in each response
- Adding a standard (visible) focus is not preferable here, since the user has not actively engaged with that element – I assume that’s the reason for setting the outline to none. But this doesn’t account for that fact that the
focus-visible
CSS selector would now come into play.
To me the best solution is to add
focusVisible: false
as a focus option, and removing the manually settabIndex
andoutline
. This kills the two birds with one stone.Our second related issue is that on first load of new items, the moveFocus() function isn’t called at all, but on subsequent loads it is. I would assume this is a result of using the preloaded add-on, and the focus logic not accounting for this?
Many thanks
- You must be logged in to reply to this topic.