diff --git a/src/Pages/StockTransfer/CreateTransfer.jsx b/src/Pages/StockTransfer/CreateTransfer.jsx index 90ff6e6..1ebd2ae 100644 --- a/src/Pages/StockTransfer/CreateTransfer.jsx +++ b/src/Pages/StockTransfer/CreateTransfer.jsx @@ -180,12 +180,20 @@ const CreateTransfer = () => { variant ? `Already added in the table` : 'This product is already Added' ); } + if (scanner) { + setTimeout(() => { + productInputRef.current?.focus(); + setProductSearchText(''); + }, 100); + } formProductRef?.current?.resetFields(); + if (!scanner) { setProductSearchText(''); + } return success; - }, []); + }, [scanner]); const focusProductInput = () => { // give React a tick to close modal/input blur before refocusing @@ -367,7 +375,13 @@ const CreateTransfer = () => { setVariantDetails([]); setSelectedProductForVariant(null); setSelectedVariants([]); - focusProductInput(); + + if (scanner) { + setTimeout(() => { + productInputRef.current?.focus(); + setProductSearchText(''); + }, 100); + } }; const handleDeleteRow = (index) => { @@ -618,7 +632,13 @@ const CreateTransfer = () => { setVariantDetails([]); setSelectedProductForVariant(null); setSelectedVariants([]); - focusProductInput(); + + if (scanner) { + setTimeout(() => { + productInputRef.current?.focus(); + setProductSearchText(''); + }, 100); + } }} onOk={handleAddSelectedVariants} okText="Add Selected Variants"