openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

SegmentedButton: highlight on issue

Open jasper07 opened this issue 11 years ago • 4 comments

we are using the segmented buttons to capture mandatory No / Yes

2 buttons No / Yes

on mandatory no button is selected by default,

Currently the segementedButton control does not show or highlight messages from the messageManager.

On validation we want the segmented button highlighted similar to other input fields (see pic for example).

segmented

any recommendations or suggestions?

Another request from our users is multi button selection.

Cheers John Patterson

jasper07 avatar Sep 29 '15 19:09 jasper07

Hello John,

right now the segmented button is not capable of showing input validation errors. We assumed it is a unary choice between several options and there is nothing you can validate. Multi-Selection is not planned for this control but you can use several buttons in a toolbar if you like to have such a result.

Actually i wonder how you even get a SegmentedButton control with no option selected. By default there should always be one button selected as you can see in this simple example: http://jsbin.com/masedanoxa/edit?html,css,output

You probably set an invalid key to achieve this :-) A hack but it works.

I will contact the colleagues to discuss the validation messages, they will follow up here soon.

Tracked internally as #1580123063

Cheers, Michael

Michadelic avatar Sep 30 '15 15:09 Michadelic

Hi Michael

Thanks for the response.

Wrt Multi Selection, I should really have opened as a separate issue.

  • we are using the MultiComboBox control currently, the feedback from the users is that they would like to be able to see all of the selected items (tokens), as/is the users can only see 2 or 3 selected tokens and not the complete selection. Thanks for the suggestion, we will investigate.

M: Actually i wonder how you even get a SegmentedButton control with no option selected .... You probably set an invalid key to achieve this

Exactly - however its not leaky as i followed the documentation, I would assume others are doing similar

By default or if the association is set to a falsy value (null, undefined, "", false), the first button will be selected.

Key of the selected item. If no item to this key is found in the aggregation "items", no changes will apply.

_createSegmentedButton: function() {
    var oTemplate = {
        path: this.getLookupPath(),
        template: new SegmentedButtonItem({
            key: "{Key}",
            text: "{Value}"
        })
    };

    var oAttributes = {
        select: this._fnChange,
        selectedKey: {
            path: this.getValuePath()
        },
        items: oTemplate,
        layoutData: this._oLayoutData
    };

    if (this.getMandatory()) {
        oAttributes.selectedButton = "UNSELECTED";
    }
    return new SegmentedButton(oAttributes);
},

I set the selectedKey to "UNSELECTED", knowing that this would not correspond to "No" / "Yes" or false / true, thus the initial state is no item selected.

Cheers JSP

jasper07 avatar Oct 03 '15 02:10 jasper07

Hello JSP,

thats alright, it is the fallback behavior if somebody sets a wrong key on this control. From a design perspective, this control was intended to always have an entry selected however.

Keeping this issue open for the validation question, it is currently discussed in our team.

Michael

Michadelic avatar Oct 05 '15 10:10 Michadelic

Hi John,

According to SAPUI5 Interaction design team it's not a valid use case of making the SegmentedButton a form element and thus introducing overlapping functionality from RadioButtonGroup, Checkbox and/or Select.

In your case for yes/no is perfectly valid to use RadioButtonGroup/Select when only one option should be selected and none should be initialy selected and for the other scenario where all options should be visible and multiple selection needed you can use the Checkbox control instead.

Best regards, Daniel

Nanovsky avatar Jan 18 '16 15:01 Nanovsky