Skip to content
This repository
Browse code

Merge pull request #786 from dcporter/master

Clicking on a content-less collection view results in a thrown error.
  • Loading branch information...
commit 9fcbabae64ee3d09f4b5a00f4a0ef947651f5d78 2 parents e757e10 + c1ac473
Tyler Keating publickeating authored
13 frameworks/desktop/tests/views/collection/mouse.js
@@ -153,6 +153,19 @@ test("first responder", function() {
153 153 equals(view.get('isFirstResponder'), YES, 'view.isFirstResponder should be YES after mouse down');
154 154 });
155 155
  156 +test("clicking on a collection view with null content should not throw an error", function() {
  157 + var failed = NO;
  158 + view.set('content', null);
  159 + try {
  160 + var l = view.get('layer'),
  161 + evt = SC.Event.simulateEvent(l, 'mousedown');
  162 + SC.Event.trigger(l, 'mousedown', [evt]);
  163 + }
  164 + catch (e) { failed = YES; }
  165 + ok(!failed, "clicking on a collection view with null content should not throw an error");
  166 +});
  167 +
  168 +
156 169 // ..........................................................
157 170 // ctrl-click mouse down
158 171 //
5 frameworks/desktop/views/collection.js
@@ -2149,8 +2149,11 @@ SC.CollectionView = SC.View.extend(SC.CollectionViewDelegate, SC.CollectionConte
2149 2149 @returns {Boolean} Usually YES.
2150 2150 */
2151 2151 mouseDown: function(ev) {
  2152 + var content = this.get('content');
  2153 +
  2154 + if (!content) return this.get('isSelectable');
  2155 +
2152 2156 var itemView = this.itemViewForEvent(ev),
2153   - content = this.get('content'),
2154 2157 contentIndex = itemView ? itemView.get('contentIndex') : -1,
2155 2158 info, anchor, sel, isSelected, modifierKeyPressed, didSelect = NO,
2156 2159 allowsMultipleSel = content.get('allowsMultipleSelection');

0 comments on commit 9fcbaba

Please sign in to comment.
Something went wrong with that request. Please try again.