Fix search for elements on current route path

This commit is contained in:
Angelina Filippova 2021-02-09 02:26:39 +03:00
parent 5f9789bd24
commit de51323561

View file

@ -159,10 +159,18 @@ export default {
const tab = Object.keys(this.tabs).find(tab => {
return this.tabs[tab].settings.includes(selectedValue.group === ':pleroma' ? selectedValue.key : selectedValue.group)
})
if (tab) {
if (this.$router.currentRoute.path === `/settings/${tab}`) {
this.scrollTo(selectedValue.key)
} else if (tab) {
this.$router.push({ path: `/settings/${tab}` })
}
},
scrollTo(searchQuery) {
const selectedSetting = document.querySelector(`[data-search="${searchQuery}"]`)
if (selectedSetting) {
selectedSetting.scrollIntoView({ block: 'start', behavior: 'smooth' })
}
},
querySearch(queryString, cb) {
const results = this.searchData.filter(searchObj => searchObj.search.find(el => el.includes(queryString.toLowerCase())))
.map(searchObj => {