Skip to content

Commit

Permalink
Clear selection before creating new annotation
Browse files Browse the repository at this point in the history
Clear any selection that exists in the sidebar before creating a new
annotation. Otherwise the new annotation with its form open for the user
to type in won't be visible because it's not part of the selection.
  • Loading branch information
seanh committed Dec 18, 2015
1 parent b8663be commit 87e8de6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Unreleased
==========

Features
--------

- Clear any selection that exists in the sidebar before creating a new
annotation. Fixes a usability issue that the new annotation with its form
open for the user to type in wouldn't be visible because it wasn't part of
the selection. (#2817)


0.8.7 (2015-12-18)
==================

Expand Down
6 changes: 6 additions & 0 deletions h/static/scripts/app-controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ module.exports = class AppController
$scope.search.query = ''
annotationUI.clearSelectedAnnotations()

$rootScope.$on('beforeAnnotationCreated', (event, data) ->
if data.$highlight
return
$scope.clearSelection()
)

$scope.search =
query: $location.search()['q']

Expand Down
22 changes: 22 additions & 0 deletions h/static/scripts/test/app-controller-test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,28 @@ describe 'AppController', ->
$scope.$broadcast(events.USER_CHANGED, {initialLoad: false})
assert.calledOnce(fakeRoute.reload)

describe 'on "beforeAnnotationCreated"', ->
it 'calls $scope.clearSelection()', ->
createController()
sandbox.spy($scope, 'clearSelection')

$rootScope.$emit('beforeAnnotationCreated', {})

assert(
$scope.clearSelection.called
'It should clear any selection that exists in the sidebar before '
'creating a new annotation. Otherwise the new annotation with its '
'form open for the user to type in won\'t be visible because it\'s '
'not part of the selection.')

it 'doesn\'t call $scope.clearSelection() when a highlight is created', ->
createController()
sandbox.spy($scope, 'clearSelection')

$rootScope.$emit('beforeAnnotationCreated', {$highlight: true})

assert $scope.clearSelection.notCalled

describe 'logout()', ->
it 'prompts the user if there are drafts', ->
fakeDrafts.count.returns(1)
Expand Down

0 comments on commit 87e8de6

Please sign in to comment.