Skip to content

Commit be2857d

Browse files
authored
Merge pull request #324 from CMSgov/fix-haslinks
QPPA-10258: fix hashlinks
2 parents 5c8f36c + 44b9201 commit be2857d

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/app/components/references/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const measurementsTitleAndId = {
2828
'Proportion': 'proportion-measurements',
2929
'Non-Proportion': 'non-proportion-measurements',
3030
'CQM Single-Performance Rate': 'single-performance-rate-measurements',
31-
'QCDR Single-Performance Rate': 'single-performance-rate-measurements',
31+
'QCDR Single-Performance Rate': 'single-performance-rate-measurements-qcdr',
3232
'Multi-Performance Rate': 'multi-performance-rate-measurements',
3333
'Multi-Performance Rate Stratum': 'stratum',
3434
};

src/app/components/references/measurements.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Measurements: React.FC<DocPageProps> = ({dataTestId}: DocPageProps) => {
1111
<ul>
1212
{Object.entries(measurementsTitleAndId).map(([title, id], i) =>
1313
<li key={i}>
14-
<LinkToId to={`#${id}`} text={title} />
14+
<LinkToId to={`#${id}`} text={title} offset='120' />
1515
</li>,
1616
)}
1717
</ul>

src/shared/link-to-id.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import { HTMLAttributes } from 'react';
2-
31
import { HashLink } from '@xzar90/react-router-hash-link';
42

5-
export const LinkToId = ({ to, text, offset = '1', attrs }: { to: string, text: string, offset?: string, attrs?: HTMLAttributes<object> }) => {
3+
export const LinkToId = ({ to, text, offset = '1' }: { to: string, text: string, offset?: string }) => {
64
return (
75
<HashLink
8-
to={!to.includes('#') ? `${to}#${to}` : to}
6+
smooth to={!to.includes('#') ? `${to}#${to}` : to}
97
scroll={el => {
10-
el.scrollIntoView(true);
11-
window.scrollBy({ top: -Number(offset), behavior: 'smooth' });
8+
window.scrollTo({ top: el.getBoundingClientRect().top + window.scrollY - Number(offset) });
129
}}
13-
{...attrs}
1410
>
1511
{text}
1612
</HashLink>

0 commit comments

Comments
 (0)