diff --git a/src/components/order/QuickCreateProductModal.tsx b/src/components/order/QuickCreateProductModal.tsx index 33f6702..48f4e22 100644 --- a/src/components/order/QuickCreateProductModal.tsx +++ b/src/components/order/QuickCreateProductModal.tsx @@ -58,6 +58,16 @@ export const QuickCreateProductModal: React.FC = ( }) => { const [name, setName] = useState(initialName); const [categoryCode, setCategoryCode] = useState(initialCategoryCode); + /** + * 分类**原生输入框**的文本(2026-10-16 重构)。 + * 原实现用共享组件 `SearchableSelect`:它的输入框 `value` 绑的是内部 `inputDisplay` + * (`open ? query : 选中项 label`),真机上表现为**打不进字**;下拉又是 portal 到 body 的浮层, + * 会盖住下面的「规格 / 单位 / 生产地区」⇒ 点"单位"点在分类列表上、键盘全落在分类里。 + * 换成原生 `input + datalist`:输入天然可用、无浮层、不遮挡任何字段。 + */ + const [categoryQuery, setCategoryQuery] = useState( + () => categoryOptions.find((item) => item.category_code === initialCategoryCode)?.label || '' + ); const [unit, setUnit] = useState(initialUnit); const [salePrice, setSalePrice] = useState(initialSalePrice); const [costPrice, setCostPrice] = useState(initialCostPrice); @@ -161,29 +171,37 @@ export const QuickCreateProductModal: React.FC = (
- { + const next = event.target.value; + setCategoryQuery(next); + const hit = categoryOptions.find((item) => item.label === next); + // 只有完全等于某个分类名时才回填 code;否则交给「新建分类」入口 + setCategoryCode(hit ? hit.category_code : ''); + }} placeholder={t('orders.pickCat')} - allowCreateFromQuery={Boolean(onCreateCategory)} - alwaysShowCreate={Boolean(onCreateCategory)} - createEmptyLabel={t('orders.newCategory')} - createFromQueryLabel={(q) => (q.trim() ? t('orders.newCategoryNamed', { name: q }) : t('orders.newCategory'))} - onCreateFromQuery={onCreateCategory} - hideSearchIcon - compact - className="w-full" - inputClassName="text-sm py-1" - maxListHeight="max-h-40" - /** - * ⚠️ **不要 portal(2026-10-16 真机缺陷)**:portal 会把下拉挂到 body、z-index 高于弹窗, - * 于是分类列表**盖住**下面的「规格/单位/生产地区」——点"单位"实际点在分类列表上, - * 焦点没离开分类输入框,接着敲键盘全在操作分类(截图实测)。 - * 改为弹窗内回流展开:列表把下面的字段**顶下去**而不是盖住,任何真实点击也能正常关闭。 - */ - portal={false} + className="app-input app-focus-ring w-full px-3 py-1 text-sm border rounded-lg focus:outline-none focus:ring-2" + aria-label={t('orders.category')} /> + + {categoryOptions.map((item) => ( + + {onCreateCategory ? ( + + ) : null}