Skip to content

Commit eb6cda1

Browse files
dabengpatternfly-build
authored andcommitted
List View: Inconsistent behavior for row expansion
Note: row expansion is the default behavior after onClick performed, but user can stop such default behavior by adding the sentence "return false;" to the end of onClick function body
1 parent 592440d commit eb6cda1

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

src/views/listview/list-view.component.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* <li>.onCheckBoxChange - ( function(item) ) Called to notify when a checkbox selection changes, default is none
3030
* <li>.onSelect - ( function(item, event) ) Called to notify of item selection, default is none
3131
* <li>.onSelectionChange - ( function(items) ) Called to notify when item selections change, default is none
32-
* <li>.onClick - ( function(item, event) ) Called to notify when an item is clicked, default is none
32+
* <li>.onClick - ( function(item, event) ) Called to notify when an item is clicked, default is none. Note: row expansion is the default behavior after onClick performed, but user can stop such default behavior by adding the sentence "return false;" to the end of onClick function body
3333
* <li>.onDblClick - ( function(item, event) ) Called to notify when an item is double clicked, default is none
3434
* </ul>
3535
* @param {array} actionButtons List of action buttons in each row
@@ -582,6 +582,7 @@ angular.module('patternfly.views').component('pfListView', {
582582
var alreadySelected;
583583
var selectionChanged = false;
584584
var continueEvent = true;
585+
var enableRowExpansion = ctrl.config && ctrl.config.useExpandingRows && item && !item.disableRowExpansion;
585586

586587
// Ignore disabled item clicks completely
587588
if (ctrl.checkDisabled(item)) {
@@ -624,7 +625,11 @@ angular.module('patternfly.views').component('pfListView', {
624625
}
625626
}
626627
if (ctrl.config.onClick) {
627-
ctrl.config.onClick(item, e);
628+
if (ctrl.config.onClick(item, e) !== false && enableRowExpansion) {
629+
ctrl.toggleItemExpansion(item);
630+
}
631+
} else if (enableRowExpansion) {
632+
ctrl.toggleItemExpansion(item);
628633
}
629634

630635
return continueEvent;

test/views/listview/list-view.spec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ describe('Component: pfDataList', function () {
514514
expect(alteredKebab.length).toBe(1);
515515
});
516516

517-
it('should allow expanding rows', function () {
517+
it('should allow expanding rows by clicking the caret icon', function () {
518518
var items;
519519
$scope.listConfig.useExpandingRows = true;
520520
$scope.$digest();
@@ -528,6 +528,19 @@ describe('Component: pfDataList', function () {
528528
expect(openItem.length).toBe(1);
529529
});
530530

531+
it('should allow expanding rows by clicking the main-info section', function () {
532+
var items;
533+
$scope.listConfig.useExpandingRows = true;
534+
535+
$scope.$digest();
536+
537+
items = element.find('.list-view-pf-main-info');
538+
eventFire(items[0], 'click');
539+
540+
var openItem = element.find('.list-group-item-container');
541+
expect(openItem.length).toBe(1);
542+
});
543+
531544
it('should allow expanding rows to disable individual expansion', function () {
532545
$scope.systemModel[0].disableRowExpansion = true;
533546
$scope.listConfig.useExpandingRows = true;

0 commit comments

Comments
 (0)