Reset search field when browsing to index page in single doc mode

pull/385/merge
Thibaut Courouble 8 years ago
parent 82743163c6
commit 98a6eb58cb

@ -112,18 +112,15 @@ class app.Router
@triggerRoute 'notFound'
return
isRoot: ->
location.pathname is '/'
isDocIndex: ->
@context and @context.doc and @context.entry is @context.doc.toEntry()
isIndex: ->
@context.path is '/' or (app.isSingleDoc() and @context?.entry?.isIndex())
setInitialPath: ->
# Remove superfluous forward slashes at the beginning of the path
if (path = location.pathname.replace /^\/{2,}/g, '/') isnt location.pathname
page.replace path + location.search + location.hash, null, true
if @isRoot()
if location.pathname is '/'
if path = @getInitialPathFromHash()
page.replace path + location.search, null, true
else if path = @getInitialPathFromCookie()

@ -19,7 +19,6 @@ class app.views.Search extends app.View
altS: 'stackoverflow'
@routes:
root: 'onRoot'
after: 'afterRoute'
init: ->
@ -77,9 +76,9 @@ class app.views.Search extends app.View
return
searchUrl: =>
if app.router.isRoot()
if location.pathname is '/'
@scope.searchUrl()
else if not app.router.isDocIndex()
else if not app.router.isIndex()
return
return unless value = @extractHashValue()
@ -129,11 +128,8 @@ class app.views.Search extends app.View
$.stopEvent(event)
return
onRoot: (context) =>
@reset() unless context.init
return
afterRoute: (name, context) =>
@reset() if not context.init and app.router.isIndex()
@delay @searchUrl if context.hash
@delay @autoFocus
return

Loading…
Cancel
Save