Skip to content

Commit

Permalink
fix: toc filter text not reset (#9125)
Browse files Browse the repository at this point in the history
  • Loading branch information
yufeih authored Aug 24, 2023
1 parent 35d4c69 commit 277aa86
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions templates/modern/src/toc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@ export async function renderToc(): Promise<TocNode[]> {

const disableTocFilter = meta('docfx:disabletocfilter') === 'true'

let tocFilter = disableTocFilter ? '' : (localStorage?.getItem('tocFilter') || '')

const tocUrl = new URL(tocrel.replace(/.html$/gi, '.json'), window.location.href)
const { items } = await (await fetch(tocUrl)).json()

const tocFilterUrl = disableTocFilter ? '' : (localStorage?.getItem('tocFilterUrl') || '')
let tocFilter = disableTocFilter ? '' : (localStorage?.getItem('tocFilter') || '')

if (tocFilterUrl !== tocUrl.toString()) {
tocFilter = ''
localStorage?.setItem('tocFilterUrl', '')
} else {
localStorage?.setItem('tocFilterUrl', tocUrl.toString())
}

const activeNodes = []
const selectedNodes = []
items.forEach(initTocNodes)
Expand Down

0 comments on commit 277aa86

Please sign in to comment.