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:
Flix 2024-10-03 19:22:59 +07:00 committed by GitHub
parent e8545b5280
commit 7f6472a74d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -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);
}
}}

View file

@ -20,3 +20,7 @@
cursor: pointer;
transition: box-shadow 0.2s;
}
.apiTable code {
cursor: text;
}