Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 22ac7e8

Browse files
fix: enhance focus handling (#2595)
1 parent 32aa74e commit 22ac7e8

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
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;

‎test/integration/__snapshots__/docs.test.js.snap‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`Docs Site coverpage renders and is unchanged 1`] = `
55
<div class="mask"></div>
66
<div class="cover-main"><!-- markdownlint-disable first-line-h1 -->
77
8-
<p><img src="http://127.0.0.1:4000/_media/icon.svg" data-origin="_media/icon.svg" alt="logo"></p><h1 id="docsify-500-rc1" tabindex="-1"><a href="#/?id=docsify-500-rc1" data-id="docsify-500-rc1" class="anchor"><span>docsify <small>5.0.0-rc.1</small></span></a></h1><blockquote>
8+
<p><img src="http://127.0.0.1:4000/_media/icon.svg" data-origin="_media/icon.svg" alt="logo"></p><h1 id="docsify" tabindex="-1"><a href="#/?id=docsify" data-id="docsify" class="anchor"><span>docsify <small>5.0.0-rc.1</small></span></a></h1><blockquote>
99
<p>A magical documentation site generator</p></blockquote>
1010
<ul><li>Simple and lightweight</li><li>No statically built HTML files</li><li>Multiple themes</li></ul><p><a href="#/?id=docsify" class="button primary">Get Started</a>
1111
<a href="https://github.com/docsifyjs/docsify/" target="_blank" rel="noopener" class="button secondary">GitHub</a></p><!-- ![color](#f0f0f0) -->

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /