Skip to content

Commit

Permalink
fix(website): APITable component should navigate to anchor less agres…
Browse files Browse the repository at this point in the history
…sively (#10534)

Co-authored-by: Flix <flixy121@gmail.com>
Co-authored-by: sebastien <lorber.sebastien@gmail.com>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent e8545b5 commit 7f6472a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions website/src/components/APITable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}}
Expand Down
4 changes: 4 additions & 0 deletions website/src/components/APITable/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@
cursor: pointer;
transition: box-shadow 0.2s;
}

.apiTable code {
cursor: text;
}

0 comments on commit 7f6472a

Please sign in to comment.