! Fix searching (2nd time onward) in channel view broken (#3073)

This commit is contained in:
PikachuEXE 2023-01-20 08:00:29 +08:00 committed by GitHub
parent 28ee117709
commit 590f3a6121
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -676,12 +676,13 @@ export default defineComponent({
}
}
// `currentTabNode` can be `null` on 2nd+ search
const currentTabNode = document.querySelector('.tabs > .tab[aria-selected="true"]')
// `newTabNode` can be `null` when `tab` === "search"
const newTabNode = document.getElementById(`${tab}Tab`)
document.querySelector('.tabs > .tab[tabindex="0"]').setAttribute('tabindex', '-1')
document.querySelector('.tabs > .tab[tabindex="0"]')?.setAttribute('tabindex', '-1')
newTabNode?.setAttribute('tabindex', '0')
currentTabNode.setAttribute('aria-selected', 'false')
currentTabNode?.setAttribute('aria-selected', 'false')
newTabNode?.setAttribute('aria-selected', 'true')
this.currentTab = tab
newTabNode?.focus({ focusVisible: true })