From 6dd8e4363500a7dd4192c9fd8233ab8238cabd27 Mon Sep 17 00:00:00 2001 From: Roland Date: Fri, 19 Jun 2026 13:19:56 -0600 Subject: [PATCH] Inventory select options can be typed (commas were ignored). --- .../components/inventory/FieldSchemaEditor.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/components/inventory/FieldSchemaEditor.js b/app/src/components/inventory/FieldSchemaEditor.js index 30becf0a..2a9f7a67 100644 --- a/app/src/components/inventory/FieldSchemaEditor.js +++ b/app/src/components/inventory/FieldSchemaEditor.js @@ -44,12 +44,19 @@ export function FieldSchemaEditor({fields, open, onClose, onSave}) { // Fill any missing keys from labels and normalize order. const cleaned = draft .filter(f => f.label || f.key) - .map((f, index) => ({ - ...f, - key: f.key || slugifyKey(f.label), - label: f.label || f.key, - order: index, - })); + .map((f, index) => { + const field = { + ...f, + key: f.key || slugifyKey(f.label), + label: f.label || f.key, + order: index, + }; + // Clean select options here (not on every keystroke) so commas survive while typing. + if (f.type === 'select') { + field.options = (f.options || []).map(s => s.trim()).filter(Boolean); + } + return field; + }); await onSave(cleaned); onClose(); }; @@ -96,11 +103,11 @@ export function FieldSchemaEditor({fields, open, onClose, onSave}) { placeholder='Default unit' onChange={(e, data) => update(index, {unit: data.value})}/>} {f.type === 'select' && + /* Keep the raw split (no trim/filter) so typing a comma to start the next option + isn't swallowed mid-edit; options are trimmed/cleaned on save(). */ update(index, { - options: e.target.value.split(',').map(s => s.trim()).filter(Boolean) - })}/>} + onChange={e => update(index, {options: e.target.value.split(',')})}/>}