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

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=15609669#comment-15609669 ] 

Brian Jones commented on WICKET-6261:
-------------------------------------

IMO this is a bug rather than an improvement.

> 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
>            Priority: Minor
>              Labels: patch-available
>         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)