Permalink
Browse files

fix(docz-theme-default): support chinese input method (#182)

support input method (Chinese) and deleting searching words backwards
  • Loading branch information...
Gavin1995 authored and pedronauck committed Aug 2, 2018
1 parent 24f8337 commit 94544a6bde8760c17281c74e7d6bffd9f64c9c1f
Showing with 11 additions and 2 deletions.
  1. +1 −0 .gitignore
  2. +10 −2 packages/docz-theme-default/src/components/shared/Sidebar/index.tsx
@@ -32,3 +32,4 @@ dist
.rpt2_cache
.cache
.docz
.idea
@@ -134,6 +134,7 @@ interface State {
state: {
docs?: Entry[] | null
searching?: boolean
lastVal: string
}
}

@@ -156,7 +157,7 @@ const mapper = {
config: <ThemeConfig />,
docs: <Docs />,
media: <Media />,
state: <State initial={{ docs: null, searching: false }} />,
state: <State initial={{ docs: null, searching: false, lastVal: '' }} />,
toggle: <Toggle initial={true} />,
}

@@ -190,7 +191,14 @@ export const Sidebar = () => (
const docsWithoutMenu = docs.filter((doc: Entry) => !doc.menu)

const fromMenu = (menu: string) => docs.filter(doc => doc.menu === menu)
const search = (val: string) => match(docs, val, { keys: ['name'] })
const search = (val: string) => {
const change = !val.startsWith(state.lastVal)
setState({
lastVal: val,
})
if (change) return match(initialDocs, val, { keys: ['name'] })
return match(docs, val, { keys: ['name'] })
}

const handleSearchDocs = (val: string) => {
const isEmpty = val.length === 0

0 comments on commit 94544a6

Please sign in to comment.