Commit e2f6df2
authored
feat: Dialog EDS 2.0 (#4956)
* feat: add Dialog component to next/
Native <dialog>-based modal with compound API: Dialog.Header,
Dialog.Title, Dialog.Content, Dialog.Actions. Controlled via open +
onOpenChange. Closes on Escape (native), backdrop click, and
optional close affordance in the header.
Includes a scrim prop (default true) toggling backdrop visibility
via data-scrim; backdrop colour is a placeholder pending Figma
spec and a future standalone Scrim component.
* feat: make Dialog width content-driven with 300px minimum
Removes the fixed default width per designer feedback. The dialog
is at least 300px wide and grows with content; consumers can set a
larger inlineSize via style or className for forms or longer copy.
New SpecificWidth story documents the override pattern. Adds a TODO
to bind 300px to a token once one exists in @equinor/eds-tokens.
* feat: auto-id Dialog.Title, add button-pattern stories, suppress UA backdrop
- Auto-generate Dialog.Title id via context + useId, default
aria-labelledby to it so consumers don't need manual id wiring.
Explicit aria-labelledby or aria-label on Dialog still wins.
- Move story group from Surface to Feedback to match the Figma
category for this component.
- Add DangerAction and SingleAction stories illustrating common
button arrangements (delete confirm, single acknowledge).
- Force ::backdrop to transparent by default; the visible 40% scrim
now only applies when [data-scrim] is set, so scrim={false} truly
hides the backdrop instead of leaving Chrome's UA 10% overlay.
- Tests: cover initial open=true, inline width override, Dialog.Actions,
auto-aria-labelledby wiring, explicit aria-labelledby/label overrides
(20 tests total, up from 14).
* fix: align Dialog header/actions gap with Figma, conform story metadata
- Header and actions gap was using horizontal-sm (12px) but Figma
specifies 8px — switched to horizontal-xs.
- Restructured the Dialog story description to follow the canonical
order proposed in #4917 (description → import → usage). Removed
the combined import-plus-JSX code block and pointed readers to the
stories below for usage examples.
* fix: address PR review — single onOpenChange call, safer backdrop, no dangling aria-labelledby
Three correctness fixes from the @claude review on PR #4956:
1. onOpenChange fired twice per close interaction (consumer's setOpen
plus the native close event handler). Track effect-driven closes via
expectedCloseRef and suppress the close-event callback when we already
know state will land on false.
2. aria-labelledby defaulted to the generated title id even when no
Dialog.Title was rendered, dangling onto a missing element. Title now
registers its id with the Dialog via context; aria-labelledby is only
set when a title is actually present.
3. Backdrop click closed the dialog on a text-selection drag that started
inside content and overshot the dialog edge. Track mousedown target so
close fires only when both mousedown and click land on the dialog.
API tweak: Dialog.Header.onClose -> closable boolean. The close button
now invokes the context-exposed close() so all close paths converge on
the native close event (single source of truth for onOpenChange).
Tests: 5 new — drag-out guard, exactly-once for backdrop/close-button/
state-driven paths, and no aria-labelledby when neither title nor label
is given. 25 tests total.
* refactor: default Dialog.Header closable to true, add Figma trailing-space note
closable now defaults to true — most dialogs want a close affordance,
and decision-forcing dialogs opt out with closable={false}. Removes
the closable prop from every story except WithoutCloseButton.
Also adds the one-word comment from the second review explaining that
'Content ' in Dialog.figma.tsx intentionally keeps the trailing space
to match the Figma layer name.
* fix: address PR review for Dialog
- drop closable prop, always render close button (Passive variant
achieved by omitting Dialog.Actions)
- make onOpenChange required
- move Storybook h1-h6 font-family reset into @layer storybook;
drop unlayered title override from dialog.css
- stabilise setRef with useCallback
* fix: address Dialog PR review from millus1 parent 8a18fb6 commit e2f6df2
10 files changed
Lines changed: 958 additions & 2 deletions
File tree
- packages/eds-core-react
- .storybook
- src/components/next
- Dialog
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
Lines changed: 186 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
0 commit comments