expressive-code / expressive-code

A text marking & annotation engine for presenting source code on the web.

Home Page:https://expressive-code.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamically add/remove `tabindex` based on if code snippet overflows

delucis opened this issue · comments

As reported in withastro/starlight#1411, Expressive Code (like Shiki and Shikiji) adds a tabindex="0" attribute to code blocks to allow keyboard users to navigate to them and scroll when overflowing. However, non-scrollable <pre> elements should not be focusable, which would require dynamically adding/removing tabindex client-side when they change size. Given Expressive Code is already adding some small amount of JS to pages for the copy button, it might be in a good position to fix this.

Some context:

Thank you for this well-researched issue! I'm absolutely in favor of implementing the suggested solution to bridge the remaining time until this works natively in Chrome as well.

As I know that one of our community members has expressed interest in providing a small native JS-based solution and I love contributions, I'll wait for the contribution and then integrate it in EC. :)

I just released the fix in version 0.34.1. Thanks again for reporting!

Ooh, very cool! Thank you @hippotastic 💖