Bug description
Bug description
Deleting a Bard set that contains a nested field whose value is stripped on save
(a revealer field, or a field hidden by an if/show_when condition) causes the
Publish form to crash on the next save with:
TypeError: Cannot use 'in' operator to search for '<key>' in null
(WebKit phrases it as TypeError: I is not an Object. (evaluating 'N in I').)
The save request never completes; the user only sees the generic "Something went wrong" toast.
Root cause
Deleting a Bard set leaves a null node at that index in the in-memory field value
(it is not persisted to the file). On save, Values.forgetValue() is called for every
conditionally-hidden / revealer field path and calls data_delete(values, path).
The missingValue() guard that is supposed to prevent this does not catch a null
intermediate, because the reduce short-circuits to null (not undefined):
// resources/js/components/publish/Values.js
missingValue(dottedKey) {
var properties = Array.isArray(dottedKey) ? dottedKey : dottedKey.split('.');
var value = properties.reduce((prev, curr) => prev && prev[curr], clone(this.values));
return value === undefined; // null === undefined -> false, so guard is skipped
}
forgetValue() therefore proceeds into data_delete(), which walks the path and hits
the null node:
function data_delete(obj, path) {
var parts = path.split('.');
while (parts.length - 1) {
var key = parts.shift();
...
obj = obj[key]; // becomes null
}
delete obj[parts[0]]; // or: `key in null` throws on the next iteration
}
How to reproduce
Create a Bard field whose set contains a nested Replicator, and give that Replicator's
set a revealer field plus a field conditioned on it. Minimal blueprint:
fields:
-
handle: text
field:
type: bard
sets:
enumeration:
display: Enumeration
fields:
-
handle: bullet_points
field:
type: replicator
sets:
bullet_point:
display: Point
fields:
-
handle: show_readmore
field:
type: revealer
-
handle: readmore_text
field:
type: text
if:
show_readmore: 'equals 1'
On an entry, add the "Enumeration" Bard set and at least one bullet_point row. Save.
Delete that Bard set.
Click Save.
Expected behavior
The entry saves. Deleting a set should not be able to crash the save flow.
Actual behavior
TypeError in data_delete (Values.js); save aborts with "Something went wrong".
Notes
Call stack: save → performSaveRequest → Values.forgetValue → data_delete.
The stored content is never corrupted — the null node exists only in the editor's
in-memory value.
Logs
Environment
- Statamic: 5.74.0 (code is identical on `6.x`)
- Laravel: 12.x
- Browser: reproduced in Safari/WebKit and Chrome
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
Bug description
Bug description
Deleting a Bard set that contains a nested field whose value is stripped on save
(a
revealerfield, or a field hidden by anif/show_whencondition) causes thePublish form to crash on the next save with:
(WebKit phrases it as
TypeError: I is not an Object. (evaluating 'N in I').)The save request never completes; the user only sees the generic "Something went wrong" toast.
Root cause
Deleting a Bard set leaves a
nullnode at that index in the in-memory field value(it is not persisted to the file). On save,
Values.forgetValue()is called for everyconditionally-hidden / revealer field path and calls
data_delete(values, path).The
missingValue()guard that is supposed to prevent this does not catch anullintermediate, because the reduce short-circuits to
null(notundefined):forgetValue()therefore proceeds intodata_delete(), which walks the path and hitsthe
nullnode:How to reproduce
Create a Bard field whose set contains a nested Replicator, and give that Replicator's
set a
revealerfield plus a field conditioned on it. Minimal blueprint:On an entry, add the "Enumeration" Bard set and at least one
bullet_pointrow. Save.Delete that Bard set.
Click Save.
Expected behavior
The entry saves. Deleting a set should not be able to crash the save flow.
Actual behavior
TypeErrorindata_delete(Values.js); save aborts with "Something went wrong".Notes
Call stack:
save→performSaveRequest→Values.forgetValue→data_delete.The stored content is never corrupted — the
nullnode exists only in the editor'sin-memory value.
Logs
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response