Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions .changeset/toast-zero-inset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[fix] A `toast.inset` edge set to `0` now puts toasts flush to that edge. Before, a zero edge counted as unset, so the toast viewport kept the provider's inset there.

@cixzhang
7 changes: 3 additions & 4 deletions docs/specs/components/Toast/Toast.spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ Consumer migration instructions belong in consumer docs and release notes.
entrance, the row collapse, and the swipe's throw run for 0.01 ms on every
pointer; a touch user
gets no opacity fade, which `design:reduced-motion` DR2 calls for.
- **A zero toast inset does not override the provider.** A `toast.inset` edge
set to 0 keeps the provider's `layerInset` on that edge; `spec:AST-059` FR6
has a set edge replace it. An inset edge opposite the position, such as
`top` for a bottom stack, moves the stack to that edge.
- **An inset edge opposite the position moves the stack.** A `toast.inset`
edge opposite the position, such as `top` for a bottom stack, moves the
stack to that edge.
Comment thread
astracat-bot[bot] marked this conversation as resolved.
Resolved
- **The viewport sets a page-level z-index.** The viewport carries
`z-index: 500`; `spec:AST-027` FR1 keeps z-index local only, and FR8 orders
floating surfaces through the browser top layer.
Expand Down
28 changes: 28 additions & 0 deletions packages/core/src/Toast/ToastViewport.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,34 @@ describe('Toast responsive layout', () => {
expect(viewport.style.insetInlineEnd).toBe('40px');
expect(getComputedStyle(viewport).width).not.toBe('100%');
});
it('lets an inset edge of 0 replace the provider value on that edge, in LTR and RTL', () => {
const edges = [
['top', 'top'],
['bottom', 'bottom'],
['start', 'insetInlineStart'],
['end', 'insetInlineEnd'],
] as const;
for (const direction of ['ltr', 'rtl'] as const) {
for (const [edge, property] of edges) {
render(
<div dir={direction}>
<ToastViewport isTopLayer={false} inset={{[edge]: 0}}>
Comment thread
astracat-bot[bot] marked this conversation as resolved.
Resolved
<ShowToastButton options={INFO_A} />
</ToastViewport>
</div>,
);
act(() => {
fireEvent.click(screen.getByText('Trigger'));
});
const viewport = screen.getByRole('region', {name: 'Notifications'});
// React writes a zero without a unit; jsdom adds `px` only to `top` and `bottom`.
expect(viewport.style[property], `${direction} ${edge}`).toMatch(
/^0(px)?$/,
);
cleanup();
}
}
});
});

describe('ToastViewport placement', () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Toast/ToastViewport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -856,16 +856,16 @@ export function ToastViewport({
const insetStyle: React.CSSProperties = {
...layerInsetProperties(layerInset),
};
if (inset?.top) {
if (inset?.top != null) {
insetStyle.top = inset.top;
}
if (inset?.bottom) {
if (inset?.bottom != null) {
insetStyle.bottom = inset.bottom;
}
Comment thread
astracat-bot[bot] marked this conversation as resolved.
Resolved
if (inset?.start) {
if (inset?.start != null) {
insetStyle.insetInlineStart = inset.start;
}
if (inset?.end) {
if (inset?.end != null) {
insetStyle.insetInlineEnd = inset.end;
}

Expand Down