|
1 | 1 | import React, {
|
2 | 2 | useState, useEffect, ReactNode, useMemo,
|
| 3 | + useRef, |
3 | 4 | } from 'react';
|
4 | 5 | import * as JsSearch from 'js-search';
|
5 | 6 | import jsonpath from 'jsonpath';
|
@@ -236,6 +237,8 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
|
236 | 237 | || config.features.search.tagSearchDropdown.collapseOnDefault === undefined),
|
237 | 238 | );
|
238 | 239 | const [visibleResources, setVisibleResources] = useState([]);
|
| 240 | + const [discoveryTopPadding, setDiscoveryTopPadding] = useState(30); |
| 241 | + const discoveryAccessibilityLinksRef = useRef(null); |
239 | 242 |
|
240 | 243 | const handleSearchChange = (ev) => {
|
241 | 244 | const { value } = ev.currentTarget;
|
@@ -340,6 +343,13 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
|
340 | 343 | }
|
341 | 344 | });
|
342 | 345 |
|
| 346 | + // to dynamically set the top padding for discovery panel to compensate for the height of the accessibility links |
| 347 | + useEffect(() => { |
| 348 | + if (discoveryAccessibilityLinksRef.current) { |
| 349 | + setDiscoveryTopPadding(30 - discoveryAccessibilityLinksRef.current.clientHeight); |
| 350 | + } |
| 351 | + }, [setDiscoveryTopPadding]); |
| 352 | + |
343 | 353 | // Set up table columns
|
344 | 354 | // -----
|
345 | 355 | const columns = config.studyColumns.map((column) => ({
|
@@ -647,11 +657,11 @@ const Discovery: React.FunctionComponent<Props> = (props: Props) => {
|
647 | 657 | // Disabling noninteractive-tabindex rule because the span tooltip must be focusable as per https://www.w3.org/TR/2017/REC-wai-aria-1.1-20171214/#tooltip
|
648 | 658 | /* eslint-disable jsx-a11y/no-noninteractive-tabindex */
|
649 | 659 | return (
|
650 |
| - <div className='discovery-container'> |
| 660 | + <div className='discovery-container' style={{ paddingTop: discoveryTopPadding }}> |
651 | 661 | {(config.features.pageTitle && config.features.pageTitle.enabled)
|
652 | 662 | && <h1 className='discovery-page-title'>{config.features.pageTitle.text || 'Discovery'}</h1>}
|
653 | 663 |
|
654 |
| - <DiscoveryAccessibilityLinks /> |
| 664 | + <DiscoveryAccessibilityLinks ref={discoveryAccessibilityLinksRef} /> |
655 | 665 |
|
656 | 666 | {/* Header with stats */}
|
657 | 667 | <div className='discovery-header'>
|
|
0 commit comments