From fa2126ad97ffa7f7fc070bfe18d7ebbde38ed8fa Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Tue, 29 Oct 2024 15:51:27 +0530 Subject: [PATCH] Fixed: both the item change buttons becomes active after changing tab As we are using indexOf method for finding the product index, but if we already have a current product set, then in that case the product from state is used for finging the index from the filteredItems list, but as the object do not have a common reference, so in this case it always return -1, resulting in buttons being in wrong state. Improved code to find the selected current product first in the filtered items list and then finding its index, so that it has a common reference --- src/views/CountDetail.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/views/CountDetail.vue b/src/views/CountDetail.vue index 6c6efca2..3782b3dc 100644 --- a/src/views/CountDetail.vue +++ b/src/views/CountDetail.vue @@ -345,7 +345,9 @@ function updateFilteredItems() { }); } if (filteredItems.value.length > 0) { - const updatedProduct = Object.keys(product.value)?.length ? product.value : filteredItems.value[0] + // As we want to get the index of the product, if we directly store the product in the updatedProduct variable it does not return the index + // as both the object becomes different because of the reference, so if we have a product, then first finding it in the filtered list to have a common reference and then getting the index + const updatedProduct = Object.keys(product.value)?.length ? filteredItems.value.find((item) => item.productId === product.value.productId && item.importItemSeqId === product.value.importItemSeqId) : filteredItems.value[0] store.dispatch("product/currentProduct", updatedProduct); updateNavigationState(filteredItems.value.indexOf(updatedProduct)); } else {