Commit eddd4a1
authored
feat(console): settings validation errors render against the fields that caused them (objectstack#4224 follow-up) (#3083)
A `SETTINGS_VALIDATION` rejection names the offending keys, and the settings page
threw all of it away — every failure collapsed into one toast carrying the
server's summary sentence, with nothing marked on the inputs.
That was not the console's fault. The server sent `fields` as a
`Record<key, message>` hung BESIDE `error.code`, a position `ApiErrorSchema`
never declared; it survived only because that schema is a plain `z.object` that
strips undeclared keys instead of rejecting them. `extractFieldErrors` reads
arrays (`details.fields` / `fields` / `validationErrors`), so a map at an
undeclared position matched nothing and returned null. objectstack#4224 moved it
to `error.details.fields` as the declared `FieldError[]` — which is what makes
this wiring a few lines rather than a parser.
- `SettingsField` gains an `error` prop, rendered in the slot the help text
occupies rather than stacked under it.
- The mark is on the CONTROL, not just beside it — `aria-invalid` plus
`aria-describedby` pointing at a `role="alert"` message, wired in `wrapper` so
every input type is covered at once. Colour is not a cue for everyone.
- Cleared per-field the moment that field is edited, and wholesale on Discard,
on reload, and on a successful save.
- Fields the server did not name stay unmarked; a failure carrying no field
array behaves exactly as before. The toast still fires alongside the marks.
Five tests drive the real post-#4224 wire body rather than a hand-tuned fixture,
and were verified to fail without the wiring.1 parent 07de839 commit eddd4a1
4 files changed
Lines changed: 362 additions & 6 deletions
File tree
- .changeset
- apps/console/src/pages/settings
- __tests__
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
| |||
132 | 142 | | |
133 | 143 | | |
134 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
135 | 162 | | |
136 | | - | |
| 163 | + | |
137 | 164 | | |
138 | 165 | | |
139 | 166 | | |
| |||
231 | 258 | | |
232 | 259 | | |
233 | 260 | | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
234 | 267 | | |
235 | 268 | | |
236 | 269 | | |
237 | | - | |
238 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
239 | 281 | | |
240 | 282 | | |
241 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
45 | 52 | | |
46 | 53 | | |
47 | 54 | | |
| |||
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
56 | 73 | | |
57 | 74 | | |
58 | 75 | | |
| |||
61 | 78 | | |
62 | 79 | | |
63 | 80 | | |
| 81 | + | |
64 | 82 | | |
65 | 83 | | |
66 | 84 | | |
| |||
127 | 145 | | |
128 | 146 | | |
129 | 147 | | |
| 148 | + | |
130 | 149 | | |
131 | 150 | | |
132 | 151 | | |
| |||
135 | 154 | | |
136 | 155 | | |
137 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
138 | 170 | | |
139 | 171 | | |
140 | 172 | | |
| |||
194 | 226 | | |
195 | 227 | | |
196 | 228 | | |
197 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
198 | 238 | | |
199 | 239 | | |
200 | 240 | | |
201 | 241 | | |
| 242 | + | |
202 | 243 | | |
203 | 244 | | |
204 | 245 | | |
| |||
211 | 252 | | |
212 | 253 | | |
213 | 254 | | |
214 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
215 | 266 | | |
216 | 267 | | |
217 | 268 | | |
| |||
0 commit comments