Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
how can google.com put a tab focus on an element that is not focusable

Please go to google.com and search for 'dictionary', navigate through tab key and select "skip to main content":

step1

After hitting enter, the dictionary element gets focused:

step2

When I inspect it, it's a div with a aria-level attribute with no tabindex.

step3

So my question is how can a non-focusable element gets focused like that?

EDIT: When I tried to save that exact div element into a global var and call focus, it never gets focused.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When you press Enter on that message, JavaScript code adds tabindex="-1" to the element and focuses it. Before Enter:

Google page with Elements panel showing no tabindex on the main content div

After:

Google page with Elements panel showing tabindex="-1" on the main content div

When focus leaves the element (presumably a blur event handler), JavaScript code removes the tabindex from the element.

You can see this if you right-click the element and reveal it in the Elements panel, then watch the element as you tab until you see that element again. For instance, if you click anywhere near the top of the body of the page after opening the Elements panel and Shift+Tab, eventually you get that same "Show main content" box again, and when you press Enter you can see the tabindex get added (and then see it get removed when you move away).

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda