-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VariantManagament: breaks when array of variants is empty #6622
Comments
I will be happy to provide a one-liner PR to prevent this issue from happening 🙆♂️ |
Hi @superdyzio thank you for the offer, but let me understand the issue first.
Here you can find the example with different values leading to empty |
we have this code providing the
when the in my opinion it's reasonable to make this resistant to such case by adding one condition: |
What I'm curious about is why it's breaking for you, because the provided code snippet should work without throwing an error: https://stackblitz.com/edit/ui5wcr-vm-saveas-ucervk?file=src%2FApp.tsx Please take a look at the StackBlitz example above and edit it in case I missed something. |
@Lukas742 I can break it by adding
in the first execution knowing that we can of course work around it by checking for falsy values, but I still think that the component should not break when I'm using a legal combination of available properties - please let me know how you see it! (I'm still down to providing a one liner PR - EDIT: actually, it's already there, feel free to reject it if I did something wrong) |
@superdyzio thanks for the explanation, I was now able to reproduce this bug. |
Describe the bug
Initially when we load our views we have empty variants array so there is no
<VariantItem>
children and alsoselectedVariant = ''
. In this case our app is breaking because of the issue here:Isolated Example
No response
Reproduction steps
No response
Expected Behaviour
Children property is typed as
ReactNode | ReactNode[]
so it should not break with empty array.Screenshots or Videos
No response
UI5 Web Components for React Version
2.4.0
UI5 Web Components Version
2.4.0
Browser
Chrome
Operating System
MacOS Sequoia 15.1
Additional Context
No response
Relevant log output
No response
Organization
SAP Fioneer
Declaration
The text was updated successfully, but these errors were encountered: