Skip to content

Commit 0872213

Browse files
authored
fix(ObjectPage): safeguard DOM node access in focus handlers (#7313)
1 parent a728467 commit 0872213

File tree

1 file changed

+8
-4
lines changed
  • packages/main/src/components/ObjectPage

1 file changed

+8
-4
lines changed

packages/main/src/components/ObjectPage/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,12 +731,16 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
731731
ref={objectPageContentRef}
732732
// prevent content scroll when elements outside the content are focused
733733
onFocus={() => {
734-
// 12px or 0.75rem margin for ui5wc border and input margins
735-
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}`;
734+
const opNode = objectPageRef.current;
735+
if (opNode) {
736+
// 12px or 0.75rem margin for ui5wc border and input margins
737+
opNode.style.scrollPaddingBlock = `${Math.ceil(12 + topHeaderHeight + TAB_CONTAINER_HEADER_HEIGHT + (!headerCollapsed && headerPinned ? headerContentHeight : 0))}px ${footerArea ? 'calc(var(--_ui5wcr-BarHeight) + 1.25rem)' : 0}`;
738+
}
736739
}}
737740
onBlur={(e) => {
738-
if (!e.currentTarget.contains(e.relatedTarget as Node)) {
739-
objectPageRef.current.style.scrollPaddingBlock = '0px';
741+
const opNode = objectPageRef.current;
742+
if (opNode && !e.currentTarget.contains(e.relatedTarget as Node)) {
743+
opNode.style.scrollPaddingBlock = '0px';
740744
}
741745
}}
742746
>

0 commit comments

Comments
 (0)