Skip to content

Commit e5383ef

Browse files
committed
Revert "fix: Sticky offset in nested AppLayout (#3013)"
This reverts commit 40eb1f8.
1 parent 830d07f commit e5383ef

File tree

3 files changed

+5
-106
lines changed

3 files changed

+5
-106
lines changed

pages/app-layout/multi-layout-with-table-sticky-header.page.tsx

-58
This file was deleted.

src/app-layout/__integ__/awsui-applayout.test.ts

+1-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import useBrowser from '@cloudscape-design/browser-test-tools/use-browser';
55

66
import createWrapper from '../../../lib/components/test-utils/selectors';
77
import { viewports } from './constants';
8-
import { getUrlParams, testIf, Theme } from './utils';
8+
import { getUrlParams, Theme } from './utils';
99

1010
import testutilStyles from '../../../lib/components/app-layout/test-classes/styles.selectors.js';
1111

@@ -197,15 +197,4 @@ describe.each(['classic', 'refresh', 'refresh-toolbar'] as Theme[])('%s', theme
197197
await expect(page.getNavPosition()).resolves.toEqual(navBefore);
198198
})
199199
);
200-
201-
testIf(theme === 'refresh-toolbar')(
202-
'should keep header visible and in position while scrolling',
203-
setupTest({ pageName: 'multi-layout-with-table-sticky-header' }, async page => {
204-
const tableWrapper = createWrapper().findTable();
205-
const { top: headerOldOffset } = await page.getBoundingBox(tableWrapper.findHeaderSlot().toSelector());
206-
await page.windowScrollTo({ top: 200 });
207-
const { top: headerNewOffset } = await page.getBoundingBox(tableWrapper.findHeaderSlot().toSelector());
208-
expect(headerOldOffset).toEqual(headerNewOffset);
209-
})
210-
);
211200
});

src/app-layout/visual-refresh-toolbar/index.tsx

+4-36
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
3-
import React, { useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
3+
import React, { useEffect, useImperativeHandle, useState } from 'react';
44

55
import { useStableCallback } from '@cloudscape-design/component-toolkit/internal';
66

@@ -9,7 +9,6 @@ import { SplitPanelSideToggleProps } from '../../internal/context/split-panel-co
99
import { fireNonCancelableEvent } from '../../internal/events';
1010
import { useControllable } from '../../internal/hooks/use-controllable';
1111
import { useIntersectionObserver } from '../../internal/hooks/use-intersection-observer';
12-
import { useMergeRefs } from '../../internal/hooks/use-merge-refs';
1312
import { useMobile } from '../../internal/hooks/use-mobile';
1413
import { useUniqueId } from '../../internal/hooks/use-unique-id';
1514
import { useGetGlobalBreadcrumbs } from '../../internal/plugins/helpers/use-global-breadcrumbs';
@@ -79,8 +78,6 @@ const AppLayoutVisualRefreshToolbar = React.forwardRef<AppLayoutProps.Ref, AppLa
7978
const [notificationsHeight, setNotificationsHeight] = useState(0);
8079
const [navigationAnimationDisabled, setNavigationAnimationDisabled] = useState(true);
8180
const [splitPanelAnimationDisabled, setSplitPanelAnimationDisabled] = useState(true);
82-
const [isNested, setIsNested] = useState(false);
83-
const rootRef = useRef<HTMLDivElement>(null);
8481

8582
const [toolsOpen = false, setToolsOpen] = useControllable(controlledToolsOpen, onToolsChange, false, {
8683
componentName: 'AppLayout',
@@ -435,45 +432,16 @@ const AppLayoutVisualRefreshToolbar = React.forwardRef<AppLayoutProps.Ref, AppLa
435432
placement.inlineSize,
436433
]);
437434

438-
/**
439-
* Returns true if the AppLayout is nested
440-
* Does not apply to iframe
441-
*/
442-
const getIsNestedInAppLayout = (element: HTMLElement | null): boolean => {
443-
let currentElement: Element | null = element?.parentElement ?? null;
444-
445-
// this traverse is needed only for JSDOM
446-
// in real browsers the globalVar will be propagated to all descendants and this loops exits after initial iteration
447-
while (currentElement) {
448-
if (getComputedStyle(currentElement).getPropertyValue(globalVars.stickyVerticalTopOffset)) {
449-
return true;
450-
}
451-
currentElement = currentElement.parentElement;
452-
}
453-
454-
return false;
455-
};
456-
457-
useLayoutEffect(() => {
458-
if (!hasToolbar) {
459-
setIsNested(getIsNestedInAppLayout(rootRef.current));
460-
}
461-
}, [hasToolbar]);
462-
463435
return (
464436
<>
465437
{/* Rendering a hidden copy of breadcrumbs to trigger their deduplication */}
466438
{!hasToolbar && breadcrumbs ? <ScreenreaderOnly>{breadcrumbs}</ScreenreaderOnly> : null}
467439
<SkeletonLayout
468-
ref={useMergeRefs(intersectionObserverRef, rootRef)}
440+
ref={intersectionObserverRef}
469441
style={{
442+
[globalVars.stickyVerticalTopOffset]: `${verticalOffsets.header}px`,
443+
[globalVars.stickyVerticalBottomOffset]: `${placement.insetBlockEnd}px`,
470444
paddingBlockEnd: splitPanelOpen && splitPanelPosition === 'bottom' ? splitPanelReportedSize : '',
471-
...(hasToolbar || !isNested
472-
? {
473-
[globalVars.stickyVerticalTopOffset]: `${verticalOffsets.header}px`,
474-
[globalVars.stickyVerticalBottomOffset]: `${placement.insetBlockEnd}px`,
475-
}
476-
: {}),
477445
...(!isMobile ? { minWidth: `${minContentWidth}px` } : {}),
478446
}}
479447
toolbar={

0 commit comments

Comments
 (0)