Skip to content

Commit 4426625

Browse files
perf(ui): prevent blockType: "$undefined" from being sent through the network (#12131)
Removes `$undefined` strings from being sent through the network when sending form state requests. When adding new array rows, we assign `blockType: undefined` which is stringified to `"$undefined"`. This is unnecessary, as simply not sending this property is equivalent, and this is only a requirement for blocks. This change will save on request size, albeit minimal. | Before | After | |--|--| |<img width="1267" alt="Untitled" src="https://github.com/user-attachments/assets/699f38bd-7db9-4a52-931d-084b8af8530f" /> | <img width="1285" alt="image" src="https://github.com/user-attachments/assets/986ecd4c-f22d-4143-ad38-0c5f52439c67" /> |
1 parent 2362899 commit 4426625

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/ui/src/forms/Form/fieldReducer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ export function fieldReducer(state: FormState, action: FieldAction): FormState {
2828

2929
const newRow: Row = {
3030
id: (subFieldState?.id?.value as string) || new ObjectId().toHexString(),
31-
blockType: blockType || undefined,
3231
collapsed: false,
3332
isLoading: true,
3433
}
3534

35+
if (blockType) {
36+
newRow.blockType = blockType
37+
}
38+
3639
withNewRow.splice(rowIndex, 0, newRow)
3740

3841
if (blockType) {

0 commit comments

Comments
 (0)