Skip to content

Commit d4b4db7

Browse files
authored
fix(ObjectPage): correct position of header feature buttons (#7374)
Also removes the redundant `anchorBarHeight` as it's always `0`. Fixes #7362
1 parent 2953025 commit d4b4db7

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

packages/main/src/components/ObjectPage/ObjectPage.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115

116116
&::part(tabstrip) {
117117
padding: 0;
118+
padding-block-start: 4px;
118119
padding-inline: var(--_ui5wcr_ObjectPage_tab_bar_inline_padding);
119120
box-shadow:
120121
inset 0 -0.0625rem var(--sapPageHeader_BorderColor),

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

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const ObjectPageCssVariables = {
3333
titleFontSize: '--_ui5wcr_ObjectPage_title_fontsize',
3434
};
3535

36-
const TAB_CONTAINER_HEADER_HEIGHT = 44;
36+
const TAB_CONTAINER_HEADER_HEIGHT = 44 + 4; // tabbar height + custom 4px padding-block-start
3737

3838
/**
3939
* A component that allows apps to easily display information related to a business object.
@@ -83,7 +83,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
8383
const prevTopHeaderHeight = useRef(0);
8484
// @ts-expect-error: useSyncRef will create a ref if not present
8585
const [componentRefHeaderContent, headerContentRef] = useSyncRef(headerArea?.ref);
86-
const anchorBarRef = useRef<HTMLDivElement>(null);
8786
const scrollEvent = useRef(undefined);
8887
const objectPageContentRef = useRef<HTMLDivElement>(null);
8988
const selectionScrollTimeout = useRef(null);
@@ -128,19 +127,17 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
128127
}, []);
129128

130129
// observe heights of header parts
131-
const { topHeaderHeight, headerContentHeight, anchorBarHeight, totalHeaderHeight, headerCollapsed } =
132-
useObserveHeights(
133-
objectPageRef,
134-
topHeaderRef,
135-
headerContentRef,
136-
anchorBarRef,
137-
[headerCollapsedInternal, setHeaderCollapsedInternal],
138-
{
139-
noHeader: !titleArea && !headerArea,
140-
fixedHeader: headerPinned,
141-
scrollTimeout,
142-
},
143-
);
130+
const { topHeaderHeight, headerContentHeight, totalHeaderHeight, headerCollapsed } = useObserveHeights(
131+
objectPageRef,
132+
topHeaderRef,
133+
headerContentRef,
134+
[headerCollapsedInternal, setHeaderCollapsedInternal],
135+
{
136+
noHeader: !titleArea && !headerArea,
137+
fixedHeader: headerPinned,
138+
scrollTimeout,
139+
},
140+
);
144141

145142
useEffect(() => {
146143
if (typeof onToggleHeaderArea === 'function' && isToggledRef.current) {
@@ -197,7 +194,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
197194
const scrollMargin =
198195
-1 /* reduce margin-block so that intersection observer detects correct section*/ +
199196
safeTopHeaderHeight +
200-
anchorBarHeight +
201197
TAB_CONTAINER_HEADER_HEIGHT +
202198
(headerPinned && !headerCollapsed ? headerContentHeight : 0);
203199
section.style.scrollMarginBlockStart = scrollMargin + 'px';
@@ -642,7 +638,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
642638
{headerArea && titleArea && (
643639
<div
644640
data-component-name="ObjectPageAnchorBar"
645-
ref={anchorBarRef}
646641
className={classNames.anchorBar}
647642
style={{
648643
top:

packages/main/src/internal/useObserveHeights.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export const useObserveHeights = (
77
pageRef,
88
topHeaderRef,
99
headerContentRef,
10-
anchorBarRef,
1110
[headerCollapsed, setHeaderCollapsed]: [boolean, Dispatch<SetStateAction<boolean>>],
1211
{
1312
noHeader,
@@ -101,8 +100,7 @@ export const useObserveHeights = (
101100
headerContentResizeObserver.disconnect();
102101
};
103102
}, [isIntersecting]);
104-
const anchorBarHeight = anchorBarRef?.current?.offsetHeight ?? 0;
105-
const totalHeaderHeight = (noHeader ? 0 : topHeaderHeight + headerContentHeight) + anchorBarHeight;
103+
const totalHeaderHeight = noHeader ? 0 : topHeaderHeight + headerContentHeight;
106104

107-
return { topHeaderHeight, headerContentHeight, anchorBarHeight, totalHeaderHeight, headerCollapsed };
105+
return { topHeaderHeight, headerContentHeight, totalHeaderHeight, headerCollapsed };
108106
};

0 commit comments

Comments
 (0)