Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/fix-profile-sheet-surface-color.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Colour mobile profile sheets with the profile's hero colour again, including the drag handle and the navigation bar inset. Restore full scrolling in the pinned-messages sheet.
39 changes: 39 additions & 0 deletions src/app/components/MobileSwipeDownModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ describe('MobileSwipeDownModal', () => {
expect(screen.getByTestId('immediate-content')).toBeInTheDocument();
});

it('applies sheetStyle to the panel', () => {
render(
<MobileSwipeDownModal
requestClose={vi.fn<() => void>()}
sheetClassName="styled-sheet"
sheetStyle={{ backgroundColor: '#663399' }}
>
{() => <div data-testid="styled-content" />}
</MobileSwipeDownModal>
);

const panel = screen.getByTestId('styled-content').closest('.styled-sheet');
expect(panel).toHaveStyle({ backgroundColor: '#663399' });
});

it('lifts the sheet clear of the keyboard with a transition, without resizing it', () => {
const viewport = mockVisualViewport(800);
let contentRenderCount = 0;
Expand Down Expand Up @@ -417,6 +432,30 @@ describe('MobileSwipeDownModal', () => {
}
});

it('leaves a marked scroll container to native scrolling at its top', async () => {
const requestClose = vi.fn<() => void>();
const restore = stubElementAnimations();

try {
render(
<MobileSwipeDownModal requestClose={requestClose}>
{() => (
<div data-mobile-sheet-no-drag="" data-testid="marked-scroller">
<div data-testid="marked-scroll-row" />
</div>
)}
</MobileSwipeDownModal>
);
await act(async () => {});

dragDown(screen.getByTestId('marked-scroll-row'), 100, 240);

expect(requestClose).not.toHaveBeenCalled();
} finally {
restore();
}
});

it('keeps refusing right after a list handed back the gesture', async () => {
const requestClose = vi.fn<() => void>();
const restore = stubElementAnimations();
Expand Down
6 changes: 4 additions & 2 deletions src/app/components/MobileSwipeDownModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentProps, RefObject } from 'react';
import type { ComponentProps, CSSProperties, RefObject } from 'react';
import React, {
createContext,
useCallback,
Expand Down Expand Up @@ -26,6 +26,7 @@ interface MobileSwipeDownModalProps {
dialogLabel?: string;
skipReturnFocusRef?: RefObject<boolean>;
sheetClassName?: string;
sheetStyle?: CSSProperties;
keyboardAware?: boolean;
}

Expand Down Expand Up @@ -78,6 +79,7 @@ export function MobileSwipeDownModal({
dialogLabel,
skipReturnFocusRef,
sheetClassName,
sheetStyle,
keyboardAware = false,
}: MobileSwipeDownModalProps) {
const sheetRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -353,7 +355,7 @@ export function MobileSwipeDownModal({
className={`${css.MessageMobileOptionsContainer} ${sheetClassName ?? ''} ${
portalRef ? css.MessageMobileOptionsContainerContained : ''
} ${animationCss.SheetEntrance}`}
style={shouldReduceMotion ? { animation: 'none' } : undefined}
style={{ ...(shouldReduceMotion ? { animation: 'none' } : undefined), ...sheetStyle }}
onPointerDown={(e: React.PointerEvent) => e.stopPropagation()}
onPointerMove={(e: React.PointerEvent) => e.stopPropagation()}
onPointerUp={(e: React.PointerEvent) => e.stopPropagation()}
Expand Down
10 changes: 0 additions & 10 deletions src/app/components/ResponsiveMenu.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export const SheetContent = style({
flexDirection: 'column',
});

export const SheetContentThemed = style({});

// Targets the caller's menu element, which may be any component. Reaching it by
// selector rather than cloneElement keeps it working when the caller does not
// forward className. The sheet panel draws the background, radius and shadow, so
Expand All @@ -47,11 +45,3 @@ globalStyle(`${SheetContent} > *:last-child`, {
paddingTop: '0 !important',
paddingBottom: `${config.space.S400} !important`,
});

globalStyle(`${SheetContent}.${SheetContentThemed} > *:last-child`, {
backgroundColor: 'var(--sheet-surface-color)',
});

globalStyle(`${SheetContent}.${SheetContentThemed} > *:last-child::after`, {
backgroundColor: 'var(--sheet-surface-color)',
});
20 changes: 10 additions & 10 deletions src/app/components/ResponsiveMenu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ vi.mock('focus-trap-react', () => ({
}));

vi.mock('./MobileSwipeDownModal', () => ({
MobileSwipeDownModal: ({ children, requestClose }: any) => (
<div data-testid="mobile-swipe-down" data-request-close={String(!!requestClose)}>
MobileSwipeDownModal: ({ children, requestClose, sheetStyle }: any) => (
<div
data-testid="mobile-swipe-down"
data-request-close={String(!!requestClose)}
style={sheetStyle}
>
<div data-testid="drag-handle">drag-handle</div>
{children()}
</div>
Expand Down Expand Up @@ -204,7 +208,7 @@ describe('ResponsiveMenu', () => {
expect(screen.getByTestId('focus-trap')).toBeInTheDocument();
});

it('applies --sheet-surface-color CSS custom property when surfaceColor is set', () => {
it('paints the sheet panel with surfaceColor so the sheet is coloured end to end', () => {
render(
<ScreenSizeProvider value={ScreenSize.Mobile}>
<ResponsiveMenu
Expand All @@ -216,12 +220,10 @@ describe('ResponsiveMenu', () => {
</ScreenSizeProvider>
);

const box = screen.getByTestId('box');
expect(box.style.getPropertyValue('--sheet-surface-color')).toBe('#663399');
expect(box.className).toContain('SheetContentThemed');
expect(screen.getByTestId('mobile-swipe-down')).toHaveStyle({ backgroundColor: '#663399' });
});

it('does not set surface-color properties when surfaceColor is absent', () => {
it('does not paint the sheet panel when surfaceColor is absent', () => {
render(
<ScreenSizeProvider value={ScreenSize.Mobile}>
<ResponsiveMenu
Expand All @@ -232,9 +234,7 @@ describe('ResponsiveMenu', () => {
</ScreenSizeProvider>
);

const box = screen.getByTestId('box');
expect(box.style.getPropertyValue('--sheet-surface-color')).toBe('');
expect(box.className).not.toContain('SheetContentThemed');
expect(screen.getByTestId('mobile-swipe-down').style.backgroundColor).toBe('');
});
});

Expand Down
10 changes: 3 additions & 7 deletions src/app/components/ResponsiveMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,8 @@ export function ResponsiveMenu({

if (isMobile) {
const sheetStyle: CSSProperties | undefined = surfaceColor
? ({ '--sheet-surface-color': surfaceColor } as CSSProperties)
? { backgroundColor: surfaceColor }
: undefined;
const sheetClassName = surfaceColor
? `${css.SheetContent} ${css.SheetContentThemed}`
: css.SheetContent;

return (
<>
Expand All @@ -113,7 +110,7 @@ export function ResponsiveMenu({
</MenuDialog>
)}
{anchor && mobile === 'sheet' && (
<MobileSwipeDownModal requestClose={requestClose}>
<MobileSwipeDownModal requestClose={requestClose} sheetStyle={sheetStyle}>
{() => (
<FocusTrap
focusTrapOptions={{
Expand All @@ -129,8 +126,7 @@ export function ResponsiveMenu({
direction="Column"
role="dialog"
aria-modal="true"
className={sheetClassName}
style={sheetStyle}
className={css.SheetContent}
>
{menu}
</Box>
Expand Down
1 change: 1 addition & 0 deletions src/app/features/room/room-pin-menu/RoomPinMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export const RoomPinMenu = forwardRef<HTMLDivElement, RoomPinMenuProps>(
<Box grow="Yes">
<Scroll
ref={scrollRef}
data-mobile-sheet-no-drag=""
size="300"
hideTrack
visibility="Hover"
Expand Down
Loading