Browse Source

Fix race-condition when auto-opening first search result

Fixes #604.
Thibaut Courouble 8 years ago
parent
commit
dcca46cd0f

+ 3 - 3
assets/javascripts/views/content/entry_page.coffee

@@ -89,8 +89,8 @@ class app.views.EntryPage extends app.View
     @entry.doc.fullName + if @entry.isIndex() then ' documentation' else " / #{@entry.name}"
     @entry.doc.fullName + if @entry.isIndex() then ' documentation' else " / #{@entry.name}"
 
 
   beforeRoute: =>
   beforeRoute: =>
-    @abort()
     @cache()
     @cache()
+    @abort()
     return
     return
 
 
   onRoute: (context) ->
   onRoute: (context) ->
@@ -107,7 +107,7 @@ class app.views.EntryPage extends app.View
   abort: ->
   abort: ->
     if @xhr
     if @xhr
       @xhr.abort()
       @xhr.abort()
-      @xhr = null
+      @xhr = @entry = null
     return
     return
 
 
   onSuccess: (response) =>
   onSuccess: (response) =>
@@ -125,7 +125,7 @@ class app.views.EntryPage extends app.View
     return
     return
 
 
   cache: ->
   cache: ->
-    return if not @entry or @cacheMap[path = @entry.filePath()]
+    return if @xhr or not @entry or @cacheMap[path = @entry.filePath()]
 
 
     @cacheMap[path] = @el.innerHTML
     @cacheMap[path] = @el.innerHTML
     @cacheStack.push(path)
     @cacheStack.push(path)

+ 1 - 1
assets/javascripts/views/sidebar/results.coffee

@@ -46,7 +46,7 @@ class app.views.Results extends app.View
     return
     return
 
 
   openFirst: ->
   openFirst: ->
-    setTimeout (=> @el.firstElementChild?.click()), 0
+    @el.firstElementChild?.click()
     return
     return
 
 
   onDocEnabled: (doc) ->
   onDocEnabled: (doc) ->