korbit-ai[bot] commented on code in PR #34067:
URL: https://github.com/apache/superset/pull/34067#discussion_r2184937481
##########
superset-frontend/packages/superset-ui-core/src/components/Button/index.tsx:
##########
@@ -90,7 +89,12 @@ export function Button(props: ButtonProps) {
const element = children as ReactElement;
let renderedChildren = [];
- if (element && element.type === Fragment) {
+ if (
+ element &&
+ (element.type === Fragment ||
+ element.type === 'span' ||
+ element?.props?.css !== undefined)
+ ) {
renderedChildren = Children.toArray(element.props.children);
} else {
Review Comment:
### Unsafe Children Property Access <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The condition to process children now includes elements with 'span' type and
elements with CSS props, but doesn't verify if these elements have the
'children' property before accessing it.
###### Why this matters
This could cause a runtime error if an element matches the type conditions
but doesn't have a 'children' property in its props.
###### Suggested change ∙ *Feature Preview*
Add a check for the existence of the children property before accessing it:
```typescript
if (
element &&
(element.type === Fragment ||
element.type === 'span' ||
element?.props?.css !== undefined) &&
element.props?.children
) {
renderedChildren = Children.toArray(element.props.children);
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e36aec46-41d0-4fc1-aaae-6247fcf36ac9/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e36aec46-41d0-4fc1-aaae-6247fcf36ac9?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e36aec46-41d0-4fc1-aaae-6247fcf36ac9?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e36aec46-41d0-4fc1-aaae-6247fcf36ac9?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e36aec46-41d0-4fc1-aaae-6247fcf36ac9)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:37b5af27-2d8d-4504-858b-bff82e59d87e -->
[](37b5af27-2d8d-4504-858b-bff82e59d87e)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]