Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dojox/form/CheckedMultiSelect can not be cleared programatically probably due to a bug in dijit/form/_FormSelectWidgetMixin #183

Open
igorbga opened this issue Jun 25, 2020 · 1 comment

Comments

@igorbga
Copy link

igorbga commented Jun 25, 2020

Description:
I have a CheckedMultiSelect widget configured to allow multiple values, if I call:

mywidget.set("value", ["value1", "value2"]);

Selects the two values as expected.
If I call:

mywidget.set("value", []);

Expected behaviour:
No value should be selected in the widgets and all the checkboxes should appear unchecked.

Actual behaviour:
The already selected checkboxes remain checked. Interestingly though, if you click in a different checkbox than the already selected one you will notice that the others are unchecked.

Doing mywidget.set("value", "") doesn't solve the problem either.

How to reproduce:
See this Fiddle: http://jsfiddle.net/41Lh0zoj/

More info:
I think that the problem is exactly here:

if(typeof val == "undefined" || typeof val[0] == "undefined"){

I don't think that checking 'typeof val[0] == "undefined"' is right, because like in this case, val might be an empty array and that seems perfectly fine to me. Doing this additional checks avoids calling _setDiaplsy and _updateSelection which is causing the reported problem.

@nzall
Copy link

nzall commented May 5, 2022

The way we clear a CheckedMultiSelect in our project is as follows:

checkedMultiSelect._resetValue = [];
checkedMultiSelect.reset();
checkedMultiSelect._updateSelection();

If the original _resetValue is important to be retained, you can store this in a temporary variable and then afterwards restore it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants