Ticket #150 (closed defect: fixed)
Selection control formatting error
| Reported by: | jgou | Owned by: | mpo |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.3 |
| Component: | modules/kauri-forms | Version: | trunk |
| Keywords: | Cc: |
Description
If you use a selection-control, and allow it to have multple selections (@multple=true), you get an error when you deselect everything. The 'formatting error' doens't disappear until the page is refreshed, even when you select something afterwards.
Change History
comment:2 Changed 4 years ago by jgou
- Milestone changed from 0.3 to 0.4
I applied the above patch in [933].
Issue stays open for possible further review, but this is not required for 0.3 .
comment:3 follow-up: ↓ 4 Changed 4 years ago by mpo
Hm, I think this changes the semantics of the valueEquals().
if (thatValue == undefined)
return thisValue == undefined
would keep things more aligned, but most probably will re-introduce your error, since that just doubles the first step of $.valueCompare()
Could you elaborate on the error that was thrown, and assess that valueChanged really is the location causing it?
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 4 years ago by jgou
Replying to mpo:
Hm, I think this changes the semantics of the valueEquals().
if (thatValue == undefined)
return thisValue == undefined
would keep things more aligned, but most probably will re-introduce your error, since that just doubles the first step of $.valueCompare()
Could you elaborate on the error that was thrown, and assess that valueChanged really is the location causing it?
The method $.valueCompare(1, undefined) throws "TypeError: b is undefined" (which is later on displayed as a Formatting error), because it only checks for the second argument being undefined when the first is.
"if (thatValue == undefined)
return thisValue == undefined"
does therefore not re-introduce the error.
comment:5 in reply to: ↑ 4 ; follow-up: ↓ 6 Changed 4 years ago by jgou
Replying to jgou:
Replying to mpo:
Hm, I think this changes the semantics of the valueEquals().
if (thatValue == undefined)
return thisValue == undefined
would keep things more aligned, but most probably will re-introduce your error, since that just doubles the first step of $.valueCompare()
Could you elaborate on the error that was thrown, and assess that valueChanged really is the location causing it?
The method $.valueCompare(1, undefined) throws "TypeError: b is undefined" (which is later on displayed as a Formatting error), because it only checks for the second argument being undefined when the first is.
"if (thatValue == undefined)
return thisValue == undefined"
does therefore not re-introduce the error.
I just found out that valueCompare is a kauri function (in core.js) and not a jQuery function, so I guess we better patch that method instead:
if (b == undefined)
return (a == undefined);
The error is thrown in control.js 'Control.prototype.valueEquals' method, where the argument is 'undefined'.
Adding
prevents the error.
I don't know if it is best to look deeper into this issue, but for now I suggest to add the above change - which is rather harmless.