Skip to content

Commit

Permalink
EPUB/Snapshot: Fix focus getting stuck when link is hidden (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
abaevbog authored Mar 4, 2025
1 parent 915d241 commit b74b017
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/dom/common/dom-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,13 @@ abstract class DOMView<State extends DOMViewState, Data> {
...this._iframeDocument.querySelectorAll('a, area'),
...this._annotationShadowRoot.querySelectorAll('[tabindex="-1"]')
] as (HTMLElement | SVGElement)[];
focusableElements = focusableElements.filter(
el => isPageRectVisible(getBoundingPageRect(el), this._iframeWindow, 0)
);
focusableElements = focusableElements.filter((el) => {
let style = getComputedStyle(el);
// Only include visible/focusable elements that are scrolled into view
return style.visibility === 'visible'
&& style.display !== 'none'
&& isPageRectVisible(getBoundingPageRect(el), this._iframeWindow, 0);
});
focusableElements.sort((a, b) => {
let rangeA;
if (a.getRootNode() === this._annotationShadowRoot && a.hasAttribute('data-annotation-id')) {
Expand Down

0 comments on commit b74b017

Please sign in to comment.