Skip to content

fix(ObjectPage): safeguard DOM node access in focus handlers #7313

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

Merged
merged 1 commit into from
May 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/main/src/components/ObjectPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -731,12 +731,16 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
ref={objectPageContentRef}
// prevent content scroll when elements outside the content are focused
onFocus={() => {
// 12px or 0.75rem margin for ui5wc border and input margins
objectPageRef.current.style.scrollPaddingBlock = `${Math.ceil(12 + topHeaderHeight + TAB_CONTAINER_HEADER_HEIGHT + (!headerCollapsed && headerPinned ? headerContentHeight : 0))}px ${footerArea ? 'calc(var(--_ui5wcr-BarHeight) + 1.25rem)' : 0}`;
const opNode = objectPageRef.current;
if (opNode) {
// 12px or 0.75rem margin for ui5wc border and input margins
opNode.style.scrollPaddingBlock = `${Math.ceil(12 + topHeaderHeight + TAB_CONTAINER_HEADER_HEIGHT + (!headerCollapsed && headerPinned ? headerContentHeight : 0))}px ${footerArea ? 'calc(var(--_ui5wcr-BarHeight) + 1.25rem)' : 0}`;
}
}}
onBlur={(e) => {
if (!e.currentTarget.contains(e.relatedTarget as Node)) {
objectPageRef.current.style.scrollPaddingBlock = '0px';
const opNode = objectPageRef.current;
if (opNode && !e.currentTarget.contains(e.relatedTarget as Node)) {
opNode.style.scrollPaddingBlock = '0px';
}
}}
>
Expand Down
Loading