openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

RadioButtonGroup fires select event multiple times when changing selected index

Open DeanDavis opened this issue 11 years ago • 5 comments

I have a radiobuttongroup with three buttons. I want them all enabled and selectable. But, depending on certain parameters when the user chooses a radio button I may programmatically decide that radio button should not be chosen. In this case I would set the radio button back to the original using RadioButtonGroup.setSelectedIndex() But, this fires the select event multiple times. As an example see this jsbin http://jsbin.com/gayami/edit?html,output Selecting any radio button make the program set the selection back to index 0. But doing this fires the select event 3 times as shown in the console. The select event should fire one time - when the user selects the radio button.

DeanDavis avatar Sep 02 '15 13:09 DeanDavis

Hi, thanks for pointing this out to us, we'll provide a fix asap. Kind regards, Christiane

christianegoebels avatar Sep 02 '15 15:09 christianegoebels

tracked internally: 1580057911

christianegoebels avatar Sep 02 '15 15:09 christianegoebels

Hi,

normally when you don't want a user to select a radio button you should disable it. However, your point is valid (the event should fire once). We will provide a fix with the next patches of the latest release versions (including 1.30 which you are using).

Regards, Marin

marinparushev avatar Sep 09 '15 12:09 marinparushev

I was debugging this and was also trying to see if I could fix this. I looked at the code to understand it. This is what I observed.

  • This doesn't happen when using breakpoints.
  • I looked at the call stack and it seems to be coming from afterFocus.
  • Makes me think that it might be related to focus (afterFocus internally calls setSelectedIndex).
  • I will debug further to get some more clues and may be a fix.

Meanwhile, one can try if delaying the default index selection using setTimeout helps.

ghost avatar Sep 14 '15 15:09 ghost

Fixed.

Thanks and Kind Regards, Diana, SAPUI5 Dispatcher

DMihaylova avatar Dec 01 '16 15:12 DMihaylova