biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
13.94k stars 422 forks source link

📎 Improve diagnostic of `noPositiveTabindex` #359

Closed ematipico closed 11 months ago

ematipico commented 11 months ago

Description

Documentation: https://biomejs.dev/linter/rules/no-positive-tabindex

We have two options:

Conaclos commented 11 months ago

add a note that explains what the user should do: use 0 or -1

I don't think it makes sense to provide a code fix. This seems really unsafe to suggest using 0 instead of the current index.

vasucp1207 commented 11 months ago

Since +ve indexes are not recommended to use, the value 0 includes an element in the natural tab order of the content, also this is an unsafe fix for the elements like modal and form errors.

Conaclos commented 11 months ago

Since +ve indexes are not recommended to use, the value 0 includes an element in the natural tab order of the content, also this is an unsafe fix for the elements like modal and form errors.

Which difference between setting the tab index to 0 and just removing the tabIndex?

ematipico commented 11 months ago

Since +ve indexes are not recommended to use, the value 0 includes an element in the natural tab order of the content, also this is an unsafe fix for the elements like modal and form errors.

Which difference between setting the tab index to 0 and just removing the tabIndex?

With tabindex to 0, you make focusable even elements that usually aren't focusable by default. Keeping the tabindex is the safer choice we have.

vasucp1207 commented 11 months ago

Since +ve indexes are not recommended to use, the value 0 includes an element in the natural tab order of the content, also this is an unsafe fix for the elements like modal and form errors.

Which difference between setting the tab index to 0 and just removing the tabIndex?

With tabindex to 0, you make focusable even elements that usually aren't focusable by default. Keeping the tabindex is the safer choice we have.

Or if anyone sets +ve index on elements like button, but also at the same time we have to keep in mind that their interaction is handled automatically by the browser.