Skip to content

Commit bc2c812

Browse files
committed
feat(Page): add ref prop for main element
1 parent 7a55868 commit bc2c812

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • packages/react-core/src/components/Page

packages/react-core/src/components/Page/Page.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> {
9797
horizontalSubnav?: React.ReactNode;
9898
/** Accessible label, can be used to name main section */
9999
mainAriaLabel?: string;
100+
/** Reference for the main section of the page */
101+
mainRef?: React.RefObject<HTMLDivElement>;
100102
/** Flag indicating if the horizontal sub navigation should be in a group */
101103
isHorizontalSubnavGrouped?: boolean;
102104
/** Flag indicating if the breadcrumb should be in a group */
@@ -132,9 +134,10 @@ class Page extends Component<PageProps, PageState> {
132134
onNotificationDrawerExpand: () => null,
133135
mainComponent: 'main',
134136
getBreakpoint,
135-
getVerticalBreakpoint
137+
getVerticalBreakpoint,
138+
mainRef: undefined
136139
};
137-
mainRef = createRef<HTMLDivElement>();
140+
mainRef = this.props?.mainRef ? this.props.mainRef : createRef<HTMLDivElement>();
138141
pageRef = createRef<HTMLDivElement>();
139142
observer: any = () => {};
140143

0 commit comments

Comments
 (0)