Commit ea76ca0
fix(ui): prevent globals crash with arrays fields when lock state user is undefined in handleDocumentLocking (#15259)
### What
Fixes crash when adding items to array fields in Globals that throws
"Cannot read properties of null (reading 'id')".
### Why
When a locked document's user relationship isn't populated (deleted
user, etc.), `lockedState.user` can be `undefined`. The code tried to
access `.id` on this without checking, causing the crash.
### How
- Made `user` field optional in `LockedState` type
- Added null check before accessing `lockedState.user.id` in
`handleDocumentLocking`
- Only process lock state when a valid user exists
Closes #14915
---------
Co-authored-by: Patrik Kozak <35232443+PatrikKozak@users.noreply.github.com>1 parent 7043e3f commit ea76ca0
File tree
2 files changed
+2
-2
lines changed- packages/ui/src
- utilities
- views/Edit
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
0 commit comments