beforeEnter navigation guard not triggering when router.push() is called on the same route

I have a search engine which is not properly updating when after having searched something, I try to search something else.

When I want to search something, the search function in the search component is called:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>function search() {
const searchTerm = '/search=' + encodeURI(term.value.value)
console.log('search', term.value.value, question, searchTerm)
router.push(searchTerm)
}
</code>
<code>function search() { const searchTerm = '/search=' + encodeURI(term.value.value) console.log('search', term.value.value, question, searchTerm) router.push(searchTerm) } </code>
function search() {
    const searchTerm = '/search=' + encodeURI(term.value.value)
    console.log('search', term.value.value, question, searchTerm)
    router.push(searchTerm)
}

My vue-router for the /search=:question is as follow:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> {
path: "/search=:question",
name: "search",
component: SearchView,
beforeEnter: async (to) => {
await store.commit('setQuestion', to.params.question)
console.log('beforeEnter', store.state.question)
await store.dispatch('fetchSearchResult')
}
}
</code>
<code> { path: "/search=:question", name: "search", component: SearchView, beforeEnter: async (to) => { await store.commit('setQuestion', to.params.question) console.log('beforeEnter', store.state.question) await store.dispatch('fetchSearchResult') } } </code>
  {
    path: "/search=:question",
    name: "search",
    component: SearchView,
    beforeEnter: async (to) => {
      await store.commit('setQuestion', to.params.question)
      console.log('beforeEnter', store.state.question)
      await store.dispatch('fetchSearchResult')
    }
  }

It works as intended when I am doing the search from /, as you can see from the messages in the console:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>search What is the meaning of life? undefined /search=What%20is%20the%20meaning%20of%20life? SearchComp.vue:25
beforeEnter What is the meaning of life index.js:32
</code>
<code>search What is the meaning of life? undefined /search=What%20is%20the%20meaning%20of%20life? SearchComp.vue:25 beforeEnter What is the meaning of life index.js:32 </code>
search What is the meaning of life? undefined /search=What%20is%20the%20meaning%20of%20life? SearchComp.vue:25
beforeEnter What is the meaning of life index.js:32

Except when I’m doing the search from /search=What%20is%20the%20meaning%20of%20life, the beforeEnter navigation guard is not called but the url still changes to searchTerm:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>search How come Kropotkin looks like Santa? What is the meaning of life? /search=How%20come%20Kropotkin%20looks%20like%20Santa? SearchComp.vue:25
</code>
<code>search How come Kropotkin looks like Santa? What is the meaning of life? /search=How%20come%20Kropotkin%20looks%20like%20Santa? SearchComp.vue:25 </code>
search How come Kropotkin looks like Santa? What is the meaning of life? /search=How%20come%20Kropotkin%20looks%20like%20Santa? SearchComp.vue:25

I tried doing a setup with a parent and a child route to force vue to trigger before enter but it hasn’t worked.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> {
path: "/search",
name: "search",
children: [
{
path: ":question",
name: "searchQuestion",
component: SearchView,
beforeEnter: async (to) => {
await store.commit('setQuestion', to.params.question)
console.log('beforeEnter', store.state.question)
await store.dispatch('fetchSearchResult')
}
}
]
}
</code>
<code> { path: "/search", name: "search", children: [ { path: ":question", name: "searchQuestion", component: SearchView, beforeEnter: async (to) => { await store.commit('setQuestion', to.params.question) console.log('beforeEnter', store.state.question) await store.dispatch('fetchSearchResult') } } ] } </code>
  {
    path: "/search",
    name: "search",
    children: [
      {
        path: ":question",
        name: "searchQuestion",
        component: SearchView,
        beforeEnter: async (to) => {
          await store.commit('setQuestion', to.params.question)
          console.log('beforeEnter', store.state.question)
          await store.dispatch('fetchSearchResult')
        }
      }
    ]
  }

I also tried using beforeEach but its not suited for this use case given that I need to fetch stuff from my backend.
I guess that router.push() is just not made to trigger beforeEnter. If thats the case I should probably call search, update the store and use ref to force update my components but I’d much rather use router.push if possible.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật