From 8861ee038dfbf44da1b97f8cf91a6bb4517f86ab Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Tue, 9 Jan 2024 10:35:39 +0100 Subject: [PATCH] refs #6384 fix: redirect to same path when id change --- src/components/ui/VnSearchbar.vue | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 35f6c1548..bb54f6d31 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -72,15 +72,10 @@ async function search() { }); if (!props.redirect) return; - const rows = store.data; - const module = route.matched[1]; - if (rows.length === 1) { - const [firstRow] = rows; - await router.push({ path: `${module.path}/${firstRow.id}` }); - } else if (route.matched.length > 3) { - await router.push({ path: `/${module.path}` }); - arrayData.updateStateParams(); - } + const { matched: matches } = route; + const { path } = matches[matches.length-1]; + const newRoute = path.replace(':id', searchText.value); + await router.push(newRoute); }