fix(website): fix APITable anchor ID having extra hash (#5948)

This commit is contained in:
Joshua Chen 2021-11-15 09:16:56 +08:00 committed by GitHub
parent 1816f135f2
commit 11f9a54a32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,11 +41,12 @@ const APITableRow = forwardRef(
ref: React.RefObject<HTMLTableRowElement>,
) => {
const entryName = getText(children);
const anchor = name ? `#${name}-${entryName}` : `#${entryName}`;
const id = name ? `${name}-${entryName}` : entryName;
const anchor = `#${id}`;
const history = useHistory();
return (
<tr
id={anchor}
id={id}
tabIndex={0}
ref={history.location.hash === anchor ? ref : undefined}
onClick={() => {