You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Grigorov (JIRA)" <ji...@apache.org> on 2016/10/27 20:58:58 UTC

[jira] [Resolved] (WICKET-6261) CheckGroupSelector default selection state incorrect when the list of Checks is empty

     [ https://issues.apache.org/jira/browse/WICKET-6261?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Grigorov resolved WICKET-6261.
-------------------------------------
       Resolution: Fixed
    Fix Version/s: 8.0.0-M3
                   7.6.0
                   6.26

Thank you!

> CheckGroupSelector default selection state incorrect when the list of Checks is empty
> -------------------------------------------------------------------------------------
>
>                 Key: WICKET-6261
>                 URL: https://issues.apache.org/jira/browse/WICKET-6261
>             Project: Wicket
>          Issue Type: Improvement
>          Components: wicket
>    Affects Versions: 7.4.0
>            Reporter: Brian Jones
>            Assignee: Martin Grigorov
>            Priority: Minor
>              Labels: patch-available
>             Fix For: 6.26, 7.6.0, 8.0.0-M3
>
>         Attachments: WICKET-6261-fix.patch
>
>
> When using a CheckGroupSelector and your list of Check objects is empty, the default selection state for the select all checkbox is true, when it should be false. If there are no check boxes in the list, by extension none are 'checked'; therefore the select all check box should reflect this and not be checked by default.
> I believe the problem is in CheckSelector.updateSelectorState():
> {code}
> updateSelectorState: function(selectorId, findCheckboxes) {
> 	var checkboxes = findCheckboxes(),
> 			allChecked = true;
> 	
> 	for (var i = 0; i < checkboxes.length; i++) {
> 		if ((checkboxes[i].disabled === false) && (checkboxes[i].checked === false)) {
> 			allChecked = false;
> 			break;
> 		}
> 	}
> 	var selector = document.getElementById(selectorId);
> 	selector.checked = allChecked;
> }
> {code}
> If findCheckboxes() returns null or an empty list, the loop never executes and the allChecked variable remains set to true. A simple empty/null check on the list to determine the original value of the allChecked variable should do the trick:
> {code}
> 	allChecked = checkboxes !== null && checkboxes.length > 0;
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)