Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jake Salo
13,175 PointsWhy does this element with tabindex value of -1 still receive focus?
I am creating a UI for work which is controlled with a remote (only arrow keys), and In this one part of the UI, just one field which has the tabindex value set to '-1', still receive focus. What could cause this?
1 Answer
Steven Parker
243,318 PointsNot only the tabindex value, but the lack of an href attribute should prevent it from receiving focus. But it could get it anyway because of some CSS rules (possibly that target one of the classes), or some JavaScript code, neither of which is shown here.
Jake Salo
13,175 PointsJake Salo
13,175 PointsExactly that's what I thought... apart from the JavaScript I wrote to try to get around this. There is no code which should send focus to that element.. So any other thoughts? Haha
Steven Parker
243,318 PointsSteven Parker
243,318 PointsIt would be necessary to examine all the code (JS, CSS, and the entire HTML) to determine other possible causes. And are there other inputs that can receive focus instead?
Jake Salo
13,175 PointsJake Salo
13,175 PointsYeah I guess you're right. I can't publicly share the code, So I guess I'll start searching for bugs lol. This will be a fun week