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); }