-
Notifications
You must be signed in to change notification settings - Fork 392
feat(Page): add ref prop for main element #12588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,6 +97,8 @@ export interface PageProps extends React.HTMLProps<HTMLDivElement> { | |
| horizontalSubnav?: React.ReactNode; | ||
| /** Accessible label, can be used to name main section */ | ||
| mainAriaLabel?: string; | ||
| /** Reference for the main section of the page */ | ||
| mainRef?: React.RefObject<HTMLDivElement>; | ||
| /** Flag indicating if the horizontal sub navigation should be in a group */ | ||
| isHorizontalSubnavGrouped?: boolean; | ||
| /** Flag indicating if the breadcrumb should be in a group */ | ||
|
|
@@ -132,9 +134,10 @@ class Page extends Component<PageProps, PageState> { | |
| onNotificationDrawerExpand: () => null, | ||
| mainComponent: 'main', | ||
| getBreakpoint, | ||
| getVerticalBreakpoint | ||
| getVerticalBreakpoint, | ||
| mainRef: undefined | ||
| }; | ||
| mainRef = createRef<HTMLDivElement>(); | ||
| mainRef = this.props?.mainRef ? this.props.mainRef : createRef<HTMLDivElement>(); | ||
|
Comment on lines
+137
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Resolve The field initializer permanently captures the initial prop. If a caller supplies or replaces 🤖 Prompt for AI Agents |
||
| pageRef = createRef<HTMLDivElement>(); | ||
| observer: any = () => {}; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Prevent
mainReffrom leaking onto the outer DOM element.Because
mainRefis not destructured inrender, it remains in...restand is spread onto the page’s outer<div>, causing an invalid custom DOM prop/warning. Remove it fromrestwhile using it as the main element’s ref.🤖 Prompt for AI Agents