瀏覽代碼

handle off-screen selection

when toggling the logs button the selection is off-screen and
selection.toString() is empty even when there is a selected range.  Can
check for selection.type being "Range" instead.
Brian Gough 9 年之前
父節點
當前提交
b9804823f3
共有 1 個文件被更改,包括 4 次插入 和 1 次删除
  1. 4 1
      services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee

+ 4 - 1
services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee

@@ -442,7 +442,10 @@ define [
 
 				_hasSelection = () ->
 					selection = window.getSelection()
-					return _isSelectionWithinPDF(selection) and selection.toString() != ''
+					# check the selection type in preference to using
+					# selection.toString() as the latter is "" when the
+					# selection is hidden (e.g. while viewing logs)
+					return _isSelectionWithinPDF(selection) and selection.type is 'Range'
 
 				_isSelectionWithinPDF = (selection) ->
 					if selection.rangeCount == 0