SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.54k stars 265 forks source link

SegmentedButton: Component crashes on empty children #7788

Closed codingfabi closed 1 year ago

codingfabi commented 1 year ago

Bug Description

When adding a segmented button to an app and leaving the children empty, the app crashes (see sandbox). I understand that rendering an empty segmented button does not make much sense, however I am trying to implement a usecase where I load the children dynamically. Thus, my app crashes when the children are not (yet) defined.

Affected Component

SegmentedButton

Expected Behaviour

I expect the SegmentedButton to not crash the app.

Isolated Example

https://codesandbox.io/s/ui5-webcomponents-forked-gvvjcz?file=/index.html

Steps to Reproduce

  1. Add SegmentedButton to an app. Leave the children empty.
  2. App crashes...

Log Output, Stack Trace or Screenshots

No response

Priority

Medium

UI5 Web Components Version

1.18.0

Browser

Chrome

Operating System

No response

Additional Context

No response

Organization

SAP - WebcomponentForReact

Declaration

ilhan007 commented 1 year ago

@SAP/ui5-webcomponents-topic-b add check and early return for the items length before normalizing selection