diff --git a/src/pages/stock.tsx b/src/pages/stock.tsx index 6be785d0e426ca805ad2a6e3ff4d31271d6cd049..52e89c8eb0ddcfded24dd340558c6f4097308734 100644 --- a/src/pages/stock.tsx +++ b/src/pages/stock.tsx @@ -37,13 +37,16 @@ const Stock = () => { const toggleEditMode = (productId) => { let productsTemp = productsList; let product = productsTemp[productId]; - + product.edit = product.edit === true ? false : true; + // Set all product.edit in productsTemp to false - productsTemp.forEach((p) => { - p.edit = false; + productsTemp.forEach((p, idx) => { + if (p.edit && p.edit === true && idx !== productId) { + p.edit = false; + } }); - product.edit = product.edit === true ? false : true; + productsTemp[productId] = product; setProductsList([...productsTemp]); if (product.edit === false) {