Skip to content

fix(ObjectPage): correct position of header feature buttons #7374

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 22, 2025
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@

&::part(tabstrip) {
padding: 0;
padding-block-start: 4px;
padding-inline: var(--_ui5wcr_ObjectPage_tab_bar_inline_padding);
box-shadow:
inset 0 -0.0625rem var(--sapPageHeader_BorderColor),
Expand Down
29 changes: 12 additions & 17 deletions packages/main/src/components/ObjectPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const ObjectPageCssVariables = {
titleFontSize: '--_ui5wcr_ObjectPage_title_fontsize',
};

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

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

// observe heights of header parts
const { topHeaderHeight, headerContentHeight, anchorBarHeight, totalHeaderHeight, headerCollapsed } =
useObserveHeights(
objectPageRef,
topHeaderRef,
headerContentRef,
anchorBarRef,
[headerCollapsedInternal, setHeaderCollapsedInternal],
{
noHeader: !titleArea && !headerArea,
fixedHeader: headerPinned,
scrollTimeout,
},
);
const { topHeaderHeight, headerContentHeight, totalHeaderHeight, headerCollapsed } = useObserveHeights(
objectPageRef,
topHeaderRef,
headerContentRef,
[headerCollapsedInternal, setHeaderCollapsedInternal],
{
noHeader: !titleArea && !headerArea,
fixedHeader: headerPinned,
scrollTimeout,
},
);

useEffect(() => {
if (typeof onToggleHeaderArea === 'function' && isToggledRef.current) {
Expand Down Expand Up @@ -197,7 +194,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
const scrollMargin =
-1 /* reduce margin-block so that intersection observer detects correct section*/ +
safeTopHeaderHeight +
anchorBarHeight +
TAB_CONTAINER_HEADER_HEIGHT +
(headerPinned && !headerCollapsed ? headerContentHeight : 0);
section.style.scrollMarginBlockStart = scrollMargin + 'px';
Expand Down Expand Up @@ -642,7 +638,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
{headerArea && titleArea && (
<div
data-component-name="ObjectPageAnchorBar"
ref={anchorBarRef}
className={classNames.anchorBar}
style={{
top:
Expand Down
6 changes: 2 additions & 4 deletions packages/main/src/internal/useObserveHeights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const useObserveHeights = (
pageRef,
topHeaderRef,
headerContentRef,
anchorBarRef,
[headerCollapsed, setHeaderCollapsed]: [boolean, Dispatch<SetStateAction<boolean>>],
{
noHeader,
Expand Down Expand Up @@ -101,8 +100,7 @@ export const useObserveHeights = (
headerContentResizeObserver.disconnect();
};
}, [isIntersecting]);
const anchorBarHeight = anchorBarRef?.current?.offsetHeight ?? 0;
const totalHeaderHeight = (noHeader ? 0 : topHeaderHeight + headerContentHeight) + anchorBarHeight;
const totalHeaderHeight = noHeader ? 0 : topHeaderHeight + headerContentHeight;

return { topHeaderHeight, headerContentHeight, anchorBarHeight, totalHeaderHeight, headerCollapsed };
return { topHeaderHeight, headerContentHeight, totalHeaderHeight, headerCollapsed };
};
Loading