Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    RadioGroupItem change function passing incorrect new value parameter

    SmartClient Version (ISC_Core.js' header)
    Version v9.0p_2013-12-10 (2013-12-10)

    Browser
    Google Chrome 33.0.1750.154 m

    Problem
    We're trying to prevent users from selecting another radio option unless they confirm the change through a dialog. We always return false inside the change function, and try to set the correct value afterwards, but the new value parameter keeps returning the incorrect value after a couple of tries.

    Observations
    See sample code. Select the initial (fixed) option, then select the other options multiple times. The new value passed to the change function will be stuck to one of the initially unchecked items.

    Sample code
    Code:
    var unlocked = true;
    var radio = isc.DynamicForm.create({
        width: 500,
        fields: [{
            name: "radio_example",
            title: "Example",
            type: "radioGroup",
            width: 300,
            valueMap: {
                'item1': "Item 1",
                'item2': "Item 2",
                'item3': "Item 3"
            },
            vertical: false,
            change: function(form, field, value, oldValue) {
                var isUnlocked = unlocked;
                unlocked = false;
    
                console.log("Old:", oldValue, "New:", value);
                
                return isUnlocked;
            }
        }]
    });
    Sample output
    Selecting options 1, 2 and 3, in this order:
    Code:
    Old: undefined New: item1
    Old: item1 New: item2 
    Old: item1 New: item2

    #2
    Could anyone confirm whether this is a bug or if there is another approach for this use case?

    Comment


      #3
      Thanks for the clear test case. This issue has been addressed in the 9.0p, 9.1p and 10.0d branches. You can pick up the fix in the next nightly build (Dated April 12 or above)

      Regards
      Isomorphic Software

      Comment


        #4
        Thank you for the feedback.

        Could you please provide the code snippet for this fix? We can't really upgrade to the next nightly build right now.

        Thanks in advance.

        Comment


          #5
          @Isomorphic Would it be possible to provide the code changes for this fix? It is a critical issue in our environment, but due to the cost of regression testing we can't upgrade to the nightly build at the moment.

          Comment


            #6
            Here is some patch code to directly address this issue:
            Code:
            if (window.isc && isc.RadioGroupItem) {
            if (isc.version.contains("9.0p_2013-12-10")) {
                isc.RadioGroupItem.addProperties({
                    original_setValue:isc.RadioGroupItem.getPrototype().setValue,
                    setValue:function (newValue) {
                        var changingValue = this.$17m;
                        if (changingValue == null && this._changingValue != null) {
                            changingValue = this._changingValue;
                        }
                        var changeValue;
                        if (changingValue) {
                            changeValue = this.$17n;
                            if (changeValue == null && this._changeValue != null) changeValue = this._changeValue;
                        }
                        this.original_setValue(newValue);
                        if (changingValue && this.items != null && changeValue != newValue) {
                            var prevItem = this.itemForValue(changeValue);
                            if (prevItem) prevItem.setValue(null);
                        }
                    }
                });
            } else {
               isc.logWarn("Patch code intended for SmartClient build version 9.0p_2013-12-10 included in this application. This patch code is inapplicable to other SmartClient versions and should be removed.");
            }
            }
            This should resolve the issue for your build. I've included code to auto-disable if run against a different SmartClient version, and you should remove the patch code when you upgrade.

            A couple of notes:
            1. We avoid these hand-created patches whenever possible. A hand-created patch hasn't been run through out automated tests, so it actually is less safe in our opinion as compared to getting the latest patched build

            2. We will not be able to keep providing little patches like this - if you run into another unrelated issue we'll need you to upgrade to the latest patched build, so we don't end up with your framework code being customized and diverging from the standard (leading to unpredictable and difficult to resolve issues, etc).

            Regards
            Isomorphic Software

            Comment

            Working...
            X