Skip to content

Commit dd598c1

Browse files
authored
Skip empty field names in Firestore. (#850)
* Fix Vite errors caused by node-fetch. * Add license header. * Skip empty field names in Firestore. * Fix tests.
1 parent 89d61f4 commit dd598c1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/components/Firestore/DocumentEditor/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ describe('with basic root fields', () => {
125125
await act(async () => {
126126
getByText('add').click();
127127
});
128-
expect(onChange).toHaveBeenCalledWith({ hello: 'world', '': '' });
128+
expect(onChange).toHaveBeenCalledWith({ hello: 'world' });
129129
});
130130

131131
it('removes root-fields', () => {

src/components/Firestore/DocumentEditor/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ export function denormalize(store: Store, firestore?: Firestore): FirestoreAny {
137137
const field = store.fields[store.uuid];
138138
if (isMapField(field)) {
139139
return field.mapChildren.reduce((acc, curr) => {
140+
if (!curr.name) {
141+
// Skip fields with empty name (not allowed by Firestore SDK anyway).
142+
return acc;
143+
}
140144
acc[curr.name] = denormalize(
141145
{
142146
uuid: curr.valueId,

0 commit comments

Comments
 (0)