Skip to content

Commit d5b0e4d

Browse files
committed
fix: enhance focus handling
1 parent 5ac5a86 commit d5b0e4d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/_coverpage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![logo](_media/icon.svg)
44

5-
# docsify <small>5.0.0-rc.1</small>
5+
# docsify <small>5.0.0-rc.1</small> :id=docsify
66

77
> A magical documentation site generator
88

src/core/event/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,16 @@ export function Events(Base) {
416416

417417
// Move focus to content area
418418
if (focusEl) {
419-
focusEl.focus(settings);
419+
if (!focusEl.hasAttribute('tabindex')) {
420+
focusEl.setAttribute('tabindex', '-1');
421+
focusEl.setAttribute('data-added-tabindex', 'true');
422+
}
420423

421-
focusEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
424+
if (focusEl.hasAttribute('data-added-tabindex')) {
425+
focusEl.scrollIntoView({ behavior: 'smooth' });
426+
}
427+
428+
focusEl.focus(settings);
422429
}
423430

424431
return focusEl;

0 commit comments

Comments
 (0)