Skip to content

Commit

Permalink
Merge pull request sproutcore#786 from dcporter/master
Browse files Browse the repository at this point in the history
Clicking on a content-less collection view results in a thrown error.
  • Loading branch information
publickeating committed May 29, 2012
2 parents e757e10 + c1ac473 commit 9fcbaba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions frameworks/desktop/tests/views/collection/mouse.js
Expand Up @@ -153,6 +153,19 @@ test("first responder", function() {
equals(view.get('isFirstResponder'), YES, 'view.isFirstResponder should be YES after mouse down');
});

test("clicking on a collection view with null content should not throw an error", function() {
var failed = NO;
view.set('content', null);
try {
var l = view.get('layer'),
evt = SC.Event.simulateEvent(l, 'mousedown');
SC.Event.trigger(l, 'mousedown', [evt]);
}
catch (e) { failed = YES; }
ok(!failed, "clicking on a collection view with null content should not throw an error");
});


// ..........................................................
// ctrl-click mouse down
//
Expand Down
5 changes: 4 additions & 1 deletion frameworks/desktop/views/collection.js
Expand Up @@ -2149,8 +2149,11 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate, SC.CollectionConte
@returns {Boolean} Usually YES.
*/
mouseDown: function(ev) {
var content = this.get('content');

if (!content) return this.get('isSelectable');

var itemView = this.itemViewForEvent(ev),
content = this.get('content'),
contentIndex = itemView ? itemView.get('contentIndex') : -1,
info, anchor, sel, isSelected, modifierKeyPressed, didSelect = NO,
allowsMultipleSel = content.get('allowsMultipleSelection');
Expand Down

0 comments on commit 9fcbaba

Please sign in to comment.