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
10 changes: 10 additions & 0 deletions .changeset/35411-edge-sheet-square-corners.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@object-ui/console': patch
---

fix(console): full-height edge drawers have square corners

Clause-②: no
Metadata-protocol: none

- The console stylesheet gave every dialog surface a 1.25rem corner radius, which also rounded the left and right drawers (the notification center, the side form drawer and every other full-height Sheet). Those drawers sit against the top, side and bottom of the window, so the rounding showed as a notch at their inner corners. The rule now skips full-height edge sheets; they render with square corners. The record drawer, a floating card, now shows its own corner radius instead of the global one. Centred dialogs and bottom sheets keep the rounded corners. Drawer width, animation and content are unchanged.
119 changes: 119 additions & 0 deletions ui/apps/console/src/__tests__/edgeSheetSquareCorners-35411.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/**
* The console's extra-rounded dialog corners skip full-height edge drawers
* (objectstack#35411).
*
* `index.css` gives every `role="dialog"` surface a 1.25rem radius. A left or
* right Sheet is fixed against the top, side and bottom of the viewport, so the
* radius showed as a notch at each inner corner. The rule now skips the Sheet's
* edge variants by the `inset-y-0` class their variant carries, while centred
* dialogs and bottom sheets keep the radius.
*
* The record drawer is the exception: it is a floating card (objectstack#35854)
* that sets its own radius, so the global rule must not override it either.
*
* The selector is read from the shipped stylesheet and matched against the DOM
* the real primitives render, so a change to either side is seen here.
*/
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, expect, it } from 'vitest';
import { render, screen } from '@testing-library/react';
import {
Dialog,
DialogContent,
DialogTitle,
NavigationOverlay,
Sheet,
SheetContent,
SheetTitle,
} from '@object-ui/components';

const HERE = path.dirname(fileURLToPath(import.meta.url));
const CSS = fs.readFileSync(path.resolve(HERE, '../index.css'), 'utf8');

const DECLARATION = 'border-radius: 1.25rem !important;';

/**
* The selector of the one rule that sets the 1.25rem dialog radius: the text
* between the end of whatever precedes the rule (a closing brace or the
* comment above it) and the rule's opening brace.
*/
function roundingSelector(): string {
const at = CSS.indexOf(DECLARATION);
expect(at).toBeGreaterThan(-1);
expect(CSS.indexOf(DECLARATION, at + 1)).toBe(-1);
const open = CSS.lastIndexOf('{', at);
const start = Math.max(CSS.lastIndexOf('}', open), CSS.lastIndexOf('*/', open) + 1) + 1;
return CSS.slice(start, open).trim();
}

function renderSheet(side: 'left' | 'right' | 'bottom' | 'top'): HTMLElement {
render(
<Sheet open>
<SheetContent side={side}>
<SheetTitle>{`${side} sheet`}</SheetTitle>
</SheetContent>
</Sheet>,
);
return screen.getByRole('dialog');
}

describe('edge sheets are not rounded by the dialog corner rule (#35411)', () => {
it('the rule still targets dialogs', () => {
expect(roundingSelector()).toContain('[role="dialog"]');
});

it.each(['left', 'right'] as const)('a %s sheet is not matched', (side) => {
expect(renderSheet(side).matches(roundingSelector())).toBe(false);
});

it.each(['bottom', 'top'] as const)('a %s sheet keeps the rounded corners', (side) => {
expect(renderSheet(side).matches(roundingSelector())).toBe(true);
});

it('a centred dialog keeps the rounded corners', () => {
render(
<Dialog open>
<DialogContent>
<DialogTitle>centred</DialogTitle>
</DialogContent>
</Dialog>,
);
expect(screen.getByRole('dialog').matches(roundingSelector())).toBe(true);
});
});

describe('the record drawer keeps its own floating-card radius (#35411, #35854)', () => {
// Renders the real NavigationOverlay drawer. Its own radius is asserted on
// the className it ships: the test DOM has no compiled Tailwind, so the
// utility's computed value is not readable here.
function renderRecordDrawer(): HTMLElement {
render(
<NavigationOverlay
isOpen
isOverlay
selectedRecord={{ id: 'r1' }}
mode="drawer"
close={() => {}}
setIsOpen={() => {}}
title="Lead"
width="720px"
mainContent={<div />}
>
{() => <div>record body</div>}
</NavigationOverlay>,
);
return screen.getByRole('dialog', { name: 'Lead' });
}

it('is not matched by the global rounding rule', () => {
const card = renderRecordDrawer();
expect(card.hasAttribute('data-record-drawer-card')).toBe(true);
expect(card.matches(roundingSelector())).toBe(false);
});

it('carries its own radius class', () => {
expect(renderRecordDrawer().className.split(/\s+/)).toContain('sm:rounded-xl');
});
});
7 changes: 5 additions & 2 deletions ui/apps/console/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,11 @@ header.sticky {
background-color: hsl(135 59% 49%) !important;
}

/* iOS sheet/dialog: extra-rounded corners. */
[role="dialog"] {
/* iOS sheet/dialog: extra-rounded corners, for surfaces that float or rise from
the bottom. A full-height edge drawer (the left/right Sheet, whose variant
pins it with `inset-y-0`) meets the viewport on three edges, so it keeps
square corners. */
[role="dialog"]:not(.inset-y-0) {
border-radius: 1.25rem !important;
}

Expand Down
Loading