mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-28 17:57:48 +02:00
fix(website): APITable component should navigate to anchor less agressively (#10534)
Co-authored-by: Flix <flixy121@gmail.com> Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
parent
e8545b5280
commit
7f6472a74d
2 changed files with 10 additions and 3 deletions
|
@ -58,9 +58,12 @@ function APITableRow(
|
|||
tabIndex={0}
|
||||
ref={history.location.hash === anchor ? ref : undefined}
|
||||
onClick={(e) => {
|
||||
const isLinkClick =
|
||||
(e.target as HTMLElement).tagName.toUpperCase() === 'A';
|
||||
if (!isLinkClick) {
|
||||
const isTDClick =
|
||||
(e.target as HTMLElement).tagName.toUpperCase() === 'TD';
|
||||
const hasSelectedText = !!window.getSelection()?.toString();
|
||||
|
||||
const shouldNavigate = isTDClick && !hasSelectedText;
|
||||
if (shouldNavigate) {
|
||||
history.push(anchor);
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -20,3 +20,7 @@
|
|||
cursor: pointer;
|
||||
transition: box-shadow 0.2s;
|
||||
}
|
||||
|
||||
.apiTable code {
|
||||
cursor: text;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue