Announcement

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

    RadioGroupItem not displaying as selected

    Hi,

    I am using smartgwt version 13.0-p20230122.

    We have few RadioGroupItem for which we have set "setUseNativeRadioItems" to false, so that user can unselect by clicking the item again. In previous versions (13.0-p20221105) these where working fine. But in the current version, they are getting displayed as selected on click. However, the value is getting set on click.

    Below is the snapshot of the RadioGroupItem. When nothing is selected, the text box next to it is blank. When user selects the first option, we populate text box with the some data.

    Click image for larger version

Name:	RadioGroupItem_Non_Selected.JPG
Views:	112
Size:	1.4 KB
ID:	269593

    Click image for larger version

Name:	RadioGroupItem_Yes_Selected.JPG
Views:	86
Size:	1.8 KB
ID:	269594

    As you can see, the selection is happening, its just not displaying the selection.

    Code:
    final RadioGroupItem  item= new RadioGroupItem("flag");
    item.setUseNativeRadioItems(false); // allows radio item to be unselected
            item.setVertical(false);
            item.setFillHorizontalSpace(true);
    final FormItem handlerItem = new FormItem();
            handlerItem.addChangeHandler(event -> {
                // just need this here so item change handler is fired
            });
            item.setItemProperties(handlerItem);
            item.addChangeHandler(event -> {
                //Some logic
            });

    #2
    hi paggarwal ,

    We've addressed the issue that prevented radios from showing as selected with your test code.

    However, note that you technique is basically leveraging a framework hole to provide a way of clearing a RadioItem, but this is not a native behavior of native radio buttons, and having a radio button clear itself with a second click is probably not compliant with accessibility standards - as far as they go, the correct, accessible approach is probably a separate button that clears the value (which would already work without any framework change), an extra "None of the above"-type option, or a set of normal checkbox items with event handlers added to create mutually exclusive selection behavior.

    With that in mind - we've added RadioGroupItem.setAllowEmptyValue(), which provides a documented way of allowing radios to be toggled on and off by clicking - it works for all radios, so you can use it instead of your useNativeRadioItems setting and change() handler; but do consider how this could affect accessibility standards in your project.

    You can try out both changes in today's 13.x builds, dated February 12 or later.

    regards

    Isomorphic Support

    Comment


      #3
      Thanks, it working with the mentioned version.

      Comment

      Working...
      X