Skip to content

Commit

Permalink
Scroll to annotation editor when opening it
Browse files Browse the repository at this point in the history
This fixes #2053:

- Go to a page that has more than a screenful of
  annotations in the sidebar
- Scroll the sidebar to the very bottom
- Scroll the page to the very top, select some text and create a new annotation
  that will appear above the other annotations in the sidebar

=> The new annotation appears in the sidebar with its edit form open,
but it's off screen. From the user's POV nothing happens.

You can get the same bug by scrolling the sidebar to the top and
annotating the bottom of the page.

This commit fixes the issue by having AnnotationController emit an
"editorOpened" event whenever it opens its editor form, and having
AppController catch this event and scroll the sidebar to the annotation
that emitted the event.
  • Loading branch information
seanh committed Mar 26, 2015
1 parent dbe6041 commit 97f1fdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions h/static/scripts/controllers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class AppController
$rootScope.$on 'beforeAnnotationCreated', ->
$scope.clearSelection()

$rootScope.$on 'editorOpened', (annotation) ->
$rootScope.scrollTo(annotation)

$scope.login = ->
$scope.dialog.visible = true
identity.request {oncancel}
Expand Down
1 change: 1 addition & 0 deletions h/static/scripts/directives/annotation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ AnnotationController = [
@action = if model.id? then 'edit' else 'create'
@editing = true
@preview = 'no'
$rootScope.$emit("editorOpened", @annotation)

###*
# @ngdoc method
Expand Down

0 comments on commit 97f1fdb

Please sign in to comment.