feat(dialog): align component with fusion DS - FE-7151#7807
feat(dialog): align component with fusion DS - FE-7151#7807DipperTheDan wants to merge 11 commits intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Design-System-aligned Dialog implementation and converts the existing Dialog export into a legacy migration wrapper, updating docs/stories/tests and a couple of dependent components to match the new sizing/styling.
Changes:
- Added a new Dialog implementation under
src/components/dialog/__internal__/__next__/(styles, config, stories, tests, Playwright CT) including awithDialogHeaderHOC. - Replaced the old
Dialogimplementation with a wrapper that maps legacy props/sizes to the new API and emits deprecation warnings; moved Storybook entries underDeprecated/. - Updated consuming code/tests to reflect the new sizing/radius/background tokens (e.g. AdvancedColorPicker sizing, Alert/Confirm/Dialog tests).
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/dialog/dialog.test.tsx | Updates legacy Dialog tests for wrapper behavior, size mapping coverage, and new background/padding assertions. |
| src/components/dialog/dialog.style.ts | Removes the legacy styled-components implementation (superseded by __internal__/__next__). |
| src/components/dialog/dialog.stories.tsx | Moves legacy Dialog stories under Deprecated/Dialog. |
| src/components/dialog/dialog.pw.tsx | Updates Playwright expectations for new Dialog widths/radius and deprecation behavior. |
| src/components/dialog/dialog.mdx | Adds deprecation warning content and links to the newer Dialog docs. |
| src/components/dialog/dialog.component.tsx | Replaces legacy implementation with a migration wrapper around the new Dialog and adds legacy-to-new prop mapping. |
| src/components/dialog/dialog-test.stories.tsx | Moves legacy Dialog test stories under Deprecated/Dialog/Test. |
| src/components/dialog/internal/next/index.ts | Adds an index barrel for the new internal Dialog implementation. |
| src/components/dialog/internal/next/dialog.test.tsx | Adds RTL coverage for the new Dialog implementation (sizes, accessibility, sticky footer, etc.). |
| src/components/dialog/internal/next/dialog.style.ts | Adds new DS-token-based styles for the new Dialog (sizes, radius, keyline, footer/header behavior). |
| src/components/dialog/internal/next/dialog.stories.tsx | Adds Storybook stories demonstrating new Dialog behavior and header variants. |
| src/components/dialog/internal/next/dialog.pw.tsx | Adds Playwright CT coverage for the new Dialog implementation. |
| src/components/dialog/internal/next/dialog.mdx | Adds docs for the newer Dialog implementation (Quick Start, sizes, accessibility, examples). |
| src/components/dialog/internal/next/dialog.config.ts | Adds DS size config/tokens and types for the new Dialog. |
| src/components/dialog/internal/next/dialog.component.tsx | Introduces the new Dialog component implementation (Modal/FocusTrap/header/footer/sticky small-screen logic). |
| src/components/dialog/internal/next/dialog-test.stories.tsx | Adds test-oriented stories for the new Dialog implementation. |
| src/components/dialog/internal/next/dialog-header/dialog-header.test.tsx | Adds RTL coverage for withDialogHeader and status heading variants. |
| src/components/dialog/internal/next/dialog-header/dialog-header.component.tsx | Adds the withDialogHeader HOC and status icon heading rendering. |
| src/components/dialog/internal/next/components-test.pw.tsx | Adds Playwright CT helper fixtures for the new Dialog stories/tests. |
| src/components/dialog-full-screen/dialog-full-screen.test.tsx | Updates deprecation-warning assertions due to Dialog wrapper changes. |
| src/components/confirm/confirm.test.tsx | Removes disableCancel-related tests (reflecting changed/removed behavior). |
| src/components/alert/alert.test.tsx | Updates expected border-radius styling (now inherited from Dialog wrapper/new styles). |
| src/components/advanced-color-picker/advanced-color-picker.style.ts | Switches StyledDialogContent import to the new Dialog’s internal styles. |
| src/components/advanced-color-picker/advanced-color-picker.component.tsx | Changes Dialog size usage from legacy auto to small. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { StyledColorOptions } from "../simple-color-picker/simple-color-picker.style"; | ||
| import { StyledSimpleColor } from "../simple-color-picker/simple-color/simple-color.style"; | ||
| import { StyledDialogContent } from "../dialog/dialog.style"; | ||
| import { StyledDialogContent } from "../dialog/__internal__/__next__/dialog.style"; | ||
| import Dialog from "../dialog/dialog.component"; | ||
| import StyledIconButton from "../icon-button/icon-button.style"; | ||
| import checkerBoardSvg from "../simple-color-picker/simple-color/checker-board.svg"; |
There was a problem hiding this comment.
Importing StyledDialogContent from ../dialog/__internal__/__next__/dialog.style couples AdvancedColorPicker to Dialog’s internal implementation details. If Dialog’s internal structure changes again, this will break. Consider exposing the needed selector/styled export via a public dialog/__next__ entry point, or switch to targeting stable attributes (e.g. [data-element="dialog-content"]). Also note the existing ${StyledIconButton} overrides further down won’t apply now that Dialog’s close button is a Button in the new implementation.
| }; | ||
|
|
||
| const DialogPositioner = styled.div.attrs( | ||
| applyBaseTheme, |
There was a problem hiding this comment.
comment: fine to leave for now but we should have a wider conversation with the rest of the team about how we handle zindexing as ideally we drop the use of the legacy themes in the next versions
| wrapperRef={containerRef} | ||
| > | ||
| <DialogPositioner | ||
| $size={size} |
There was a problem hiding this comment.
praise: nice one for handling the transitive props
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 26 out of 26 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a022b01 to
1d0a5a5
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 31 out of 31 changed files in this pull request and generated 6 comments.
Comments suppressed due to low confidence (1)
src/components/confirm/confirm.component.tsx:202
disableCancelpreviously disabled the close icon as well (there was a test covering this), but Confirm now only setsdisableEscKeyand leaves the close icon enabled. This changes cancellation behaviour for existing consumers relying ondisableCancelto fully prevent cancelling. Consider restoring the old behaviour by disabling the close icon whendisableCancelis true (and/or preventingonCancelvia the close icon) and keeping Escape disabled too.
<Dialog
open={open}
onCancel={onCancel}
disableEscKey={disableCancel}
subtitle={subtitle}
title={getTitle()}
role="alertdialog"
size={size}
showCloseIcon={showCloseIcon}
topModalOverride={topModalOverride}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f1f6e97 to
729b881
Compare
edleeks87
left a comment
There was a problem hiding this comment.
Looks like there's a lot of tokens that are uppercase when they should be lower etc, there's also fallbacks which is preventing the undefined tokens from being caught
| @@ -16,12 +16,12 @@ import { getDataElementByValue } from "../../../playwright/components"; | |||
| const specialCharacters = [CHARACTERS.DIACRITICS, CHARACTERS.SPECIALCHARACTERS]; | |||
| const viewportHeights = [250, 500, 650]; | |||
| const viewportWidths = [ | |||
There was a problem hiding this comment.
comment: if these are already being captured in chromatic we don't need this
| }; | ||
|
|
||
| const applyDefaultPadding = () => css` | ||
| padding: 0 var(--spacing200); |
There was a problem hiding this comment.
comment: we should update these to use the new tokens if possible
| `; | ||
|
|
||
| const hasPaddingProps = (props: PaddingProps) => { | ||
| return ( |
There was a problem hiding this comment.
Question: do we need to check this? Wouldn't it just override if we did the following
const applyContentPadding =
(disableContentPadding = false) =>
(props: PaddingProps) => {
if (disableContentPadding) {
return css`
padding: 0;
`;
}
return css`
${applyDefaultPadding()}
${padding}
`;
};
| $size === "fullscreen" | ||
| ? css` | ||
| flex: 1; | ||
| ${applyContentPadding(Boolean(disableContentPadding))(props)} |
There was a problem hiding this comment.
suggestion: we shouldn't need to coerce to Boolean, there's a default value on the function but we dont' really need that as undefined is still falsy etc
| box-shadow: | ||
| 0 -2px 4px 0 rgba(0, 0, 0, 0.1), | ||
| 0 -10px 60px 0 rgba(0, 0, 0, 0.1); | ||
| background: var(--container-standard-bg-default, #fff); |
There was a problem hiding this comment.
| background: var(--container-standard-bg-default, #fff); | |
| background: var(--container-standard-bg-default); |
| flex-grow: 1; | ||
| padding: ${disableContentPadding | ||
| ? "0px" | ||
| : "var(--spacing300) var(--spacing400)"}; |
| box-sizing: border-box; | ||
| width: 100%; | ||
| height: var(--global-size-3XL, 72px); | ||
| padding-top: var(--global-space-comp-L, 16px); |
There was a problem hiding this comment.
| padding-top: var(--global-space-comp-L, 16px); | |
| padding-top: var(--global-space-comp-l); |
There was a problem hiding this comment.
lower case needed here and fallbacks should be removed
|
|
||
| const StyledDialogTitle = styled.div<StyledDialogTitleProps>` | ||
| background: var(--container-standard-bg-default, #fff); | ||
| padding: var(--global-space-comp-XL, 24px); |
There was a problem hiding this comment.
comment: same as above lowercase and no fallbacks etc
| { size: SIZE.MEDIUM, width: "750px" }, | ||
| { size: SIZE.MEDIUMLARGE, width: "850px" }, | ||
| { size: SIZE.LARGE, width: "960px" }, | ||
| { size: SIZE.EXTRASMALL, width: "540px" }, |
There was a problem hiding this comment.
comment: similar to above this can be removed if there's chromatic
|
|
||
| const meta: Meta<typeof Dialog> = { | ||
| title: "Dialog", | ||
| title: "Deprecated/Dialog", |
There was a problem hiding this comment.
| title: "Deprecated/Dialog", | |
| title: "Dialog", |
There was a problem hiding this comment.
We should show old and new in local/dev docs but only the public facing one in production etc. To the end consumer there shouldn't be a change when we remove legacy etc
| padding: ${disableContentPadding | ||
| ? "0px" | ||
| : "var(--spacing300) var(--spacing400)"}; | ||
| : "var(--global-space-layout-xs) var(--global-space-layout-§s)"}; |
| css` | ||
| min-width: 288px; | ||
| max-width: var(--container-size-dialog-maxW-S, 540px); | ||
| max-width: 540px; |
There was a problem hiding this comment.
Can we check with UX/DS to confirm there's no appropriate tokens to use here?
There was a problem hiding this comment.
Checked with DS. They did have some originally but they were stripped out for hard coded values. I've let the DS know that we'd prefer token values incase these values need updating in future, it'll save us a manual job.
96525d4 to
62e2273
Compare
06965f5 to
3f9df3c
Compare
3f9df3c to
d0a2997
Compare
| "^@sage/design-tokens-fusion/js/es6/(.*)$": | ||
| "@sage/design-tokens-fusion/js/common/$1", |
There was a problem hiding this comment.
I have had to add these here to avoid an error of SyntaxError: Unexpected token 'export' when running the test suite because Jest runs in a Node CJS environment and ignores node_modules by default, so the export const syntax in the ES6 token files is never transpiled.
Proposed behaviour
Current behaviour
Dialog is currently out of alignment with the Fusion DS.
Checklist
d.tsfile added or updated if requiredQA
Additional context
Due to
Dialogalso being used inAdvancedColorPicker,Alert,ConfirmandPages, some styling updates will be seen in these components. I have confirmed that this is expected with UX and I have been assured that we can accept the changes in styling that will inevitably happen due to these audit changes.Testing instructions