Skip to content

Commit 2e2b670

Browse files
pbankonieryadvr
authored andcommitted
ui: Fix behavior of multiselect in list view (apache#3161)
Hide multiselectaction buttons when selection is resetted after a action is performed Use checked prop instead of attr to show/hide triggered selection when box was clicked by a user before. How to reproduce: Select one entry in a multiSelect listView (e.g. instance list) and then deselect it again. Now click on the "select all" checkbox. The entries which were clicked previously are not displayed as selected. Select at least one entry. Use the multiSelectAction buttons to trigger an action. Wait for completion. The list refreshes and no entry is selected but the multiSelectAction buttons are displayed. Fix: Use "checked" property instead of the attribute to select all entries. This is necessary because when you checked an entry by clicking on it the property gets set and the browser is preferably using this. So setting the attribute by clicking on the "select all" checkbox had no impact anymore on the checkBox of the previously clicked entries. Hide the multiSelectAction buttons when the list is refreshed after an action is performed and no element is selected anymore.
1 parent b81171a commit 2e2b670

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

ui/scripts/ui/widgets/listView.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@
8888

8989
// Make sure the master checkbox is unselected
9090
if (multiSelect) {
91-
$instanceRow.closest('.list-view').find('input.multiSelectMasterCheckbox').attr('checked', false);
91+
var $listView = $instanceRow.closest('.list-view');
92+
$listView.find('input.multiSelectMasterCheckbox').prop('checked', false);
93+
toggleMultiSelectActions($listView, false);
9294
}
9395

9496
var externalLinkAction = action.externalLink;
@@ -882,15 +884,15 @@
882884

883885
if (multiSelect) {
884886
var $th = $('<th>').addClass('multiselect').appendTo($tr);
885-
var content = $('<input>')
887+
var $multiSelectMaster = $('<input>')
886888
.attr('type', 'checkbox')
887-
.addClass('multiSelectMasterCheckbox')
888-
.appendTo($th);
889+
.addClass('multiSelectMasterCheckbox');
890+
$multiSelectMaster.appendTo($th);
889891

890-
content.click(function() {
891-
var checked = $(this).is(':checked');
892-
$('.multiSelectCheckbox').attr('checked', checked);
893-
toggleMultiSelectActions($table.closest('.list-view'), checked);
892+
$multiSelectMaster.click(function() {
893+
var isMasterChecked = $(this).prop('checked');
894+
$('.multiSelectCheckbox').prop('checked', isMasterChecked);
895+
toggleMultiSelectActions($table.closest('.list-view'), isMasterChecked);
894896
});
895897
}
896898

0 commit comments

Comments
 (0)