fix(export): default group-by to None when unset/stale; polish

Final code review of the configurable-data-export feature: ExperimentDetail
was forwarding its on-page groupField state (defaults to '__name__') into
ExportDataModal, leaking a clustering default into the default (untouched)
export. Now passes the raw saved localStorage value, defaulting to
'__none__'. The modal also now validates the incoming groupField against
'__none__'/'__name__'/'__id__'/active subjectTemplate fields and coerces to
'__none__' otherwise, guarding against stale/deleted subject_info fields.
Plus a stale module comment fix and optional-chaining consistency fix in
listSubjectMembers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Experiments DB Dev
2026-07-19 13:59:48 -04:00
parent e65de8892a
commit 9b3d52d89b
5 changed files with 101 additions and 4 deletions
+1 -1
View File
@@ -417,7 +417,7 @@ export default function ExperimentDetail() {
dailyTemplate={dailyTemplate}
animals={animals}
subjectTemplate={subjectTemplate}
groupField={groupField}
groupField={localStorage.getItem(`exp-subject-group-${id}`) ?? '__none__'}
onClose={() => setShowExport(false)}
/>
</Modal>