Problem adding and removing Segmented options

Hi,

Prior to 7.0, I was able to dynamically add and remove options in a Segmented. I had to play some games though because a Segmented had to always have at least one option. So, I added a “dummy” option when the Segmented was constructed and initially hid the Segmented. Then, as I added options, I’d remove the dummy option and show the Segmented and keep track of how many options there were. Then, when an option was removed, when I hit zero options, I’d add the dummy item back and hide the Segmented. It was all kind of convoluted, but it DID work under 6.7.0 worked.

Now though, under 7.0.0, that is all broken, that code doesn’t work.

But, the good news is it seems like it should be easier now because I can hide the dummy option with hideOption(), so I no longer ever have to hide the Segmented. And, it seems like I don’t need to keep track of anything anymore either as a result since there will always be that one option present, but hidden (and I’m not 100% sure it even needs to be there anymore, but I’m assuming it still does).

But, it’s not working. Check out this snippet:

https://snippet.webix.com/rj7ddlr2

It’s a simple test: click the Add button, then click the Remove button. You’ll get a script error, and that’s the issue. Note that this happens whether I have that dummy option in there or not (you can uncomment it and the call to hide it, and it does it whether that option is present or not, hidden or not).

I can’t figure this out, but as far as I can tell it seems like it might be a Webix bug. Can anyone confirm if it’s a bug or if I’m doing something wrong?

Something definitely has changed in 7.0 since my previous code doesn’t work now, but this simplified code would be better anyway and it SEEMS like it should work, I just can’t tell if it’s a Webix bug or me doing something wrong.

Thanks!

Hey @fzammetti,

I can’t figure this out, but as far as I can tell it seems like it might be a Webix bug. Can anyone confirm if it’s a bug or if I’m doing something wrong?

Yep, I can confirm it, this is definitely a bug. The good news is, it has already been fixed in the version 7.0.2, which was released yesterday. If you are unable to get the latest update for some reason, the following workaround can be employed: https://snippet.webix.com/75ni3lwr.

Thanks Dzmitry! Am I correct that 7.0.2 is not available in the GPL version at this time? I just downloaded it and it appears I still get 7.0.0. If that’s the case, do you know when it would be available? Until then, I’ll have to try the workaround.

Actually, with the workaround I see a different issues… take a look…

https://snippet.webix.com/fvtf1gpk

Try adding three buttons. Notice that when you add the second, it’s not immediately highlighted. It only is highlighted when you add the third, which never gets highlighted.

Then, after you add them, go try to click them. They don’t actually do what they’re supposed to.

Any ideas about this? Bugs or my code?

try to remove lines 19 and 20
they prevent refreshing
https://snippet.webix.com/10xz2q1p

Perfect, that does the trick! Thank very much intregal!

I think with this I’m all set, at least with the workaround… would of course prefer to be on 7.0.2 GPL and not have to do it, but good enough for now.

Am I correct that 7.0.2 is not available in the GPL version at this time? I just downloaded it and it appears I still get 7.0.0. If that’s the case, do you know when it would be available?

You are correct. As is the case with every release, the GPL version gets updated every minor release (version x.x, i.e. in this case that would be version 7.1, the following update after that would be 7.2, and so on). As for the release date, the estimate is usually around 2-3 months between minor releases.

Naturally, you do get an access to every patch release (version x.x.x) if you have a PRO license.

Ok, good enough, thanks again!