You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(JumpLinks): support passing a reference to scroll element (#9961)
* feat(JumpLinks): support passing a reference to scroll HTMLElement
* docs(JumpLinks): update demo to show example with scrollableRef
* refactor(JumpLinks): getScrollableElement check if HTMLElement first
Co-authored-by: Christian Vogt <cvogt@redhat.com>
* docs(JumpLinks): mention scrollableRef as an option
---------
Co-authored-by: Christian Vogt <cvogt@redhat.com>
/** Adds an accessible label to the internal nav element. Defaults to the value of the label prop. */
23
23
'aria-label'?: string;
24
-
/** Selector for the scrollable element to spy on. Not passing a selector disables spying. */
24
+
/** Reference to the scrollable element to spy on. Takes precedence over scrollableSelector. Not passing a scrollableRef or scrollableSelector disables spying. */
Copy file name to clipboardExpand all lines: packages/react-core/src/demos/JumpLinks.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,9 +9,10 @@ import mastheadStyles from '@patternfly/react-styles/css/components/Masthead/mas
9
9
10
10
JumpLinks has a scrollspy built-in to make your implementation easier. When implementing JumpLinks be sure to:
11
11
12
-
1. Find the correct `scrollableSelector` for your page via [Firefox's debugging scrollable overflow](https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Debug_Scrollable_Overflow) or by adding `hasOverflowScroll` to a [PageSection](/components/page#pagesection) or [PageGroup](/components/page#pagegroup).
12
+
1. Find the correct scrollable element for your page via [Firefox's debugging scrollable overflow](https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Debug_Scrollable_Overflow) or by adding `hasOverflowScroll` to a [PageSection](/components/page#pagesection) or [PageGroup](/components/page#pagegroup).
13
13
- If you add `hasOverflowScroll` to a Page sub-component you should also add a relevant aria-label to that component as well.
14
-
2. Provide `href`s to your JumpLinksItems which match the `id` of elements you want to spy on. If you wish to scroll to a different item than you're linking to use the `node` prop.
14
+
2. Provide a reference to the scrollable element to `scrollableRef` prop or a CSS selector of the scrollable element to `scrollableSelector` prop.
15
+
3. Provide `href`s to your JumpLinksItems which match the `id` of elements you want to spy on. If you wish to scroll to a different item than you're linking to use the `node` prop.
15
16
16
17
### Scrollspy with subsections
17
18
@@ -141,7 +142,7 @@ ScrollspyH2 = () => {
141
142
142
143
This demo shows how jump links can be used in combination with a drawer.
143
144
144
-
The `scrollableSelector` prop passed to the jump links componentis an `id` that was placed on the `DrawerContent` component.
145
+
This demo uses a `scrollableRef` prop on the JumpLinks component, which is a React ref to the `DrawerContent` component.
0 commit comments