-
Notifications
You must be signed in to change notification settings - Fork 13
feat: React 19 migration - 1 #708
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |||||
|
|
||||||
| import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react'; | ||||||
| import { cx } from 'class-variance-authority'; | ||||||
| import { type ElementRef, forwardRef } from 'react'; | ||||||
| import styles from '../dialog/dialog.module.css'; | ||||||
| import { CloseButton } from './alert-dialog-misc'; | ||||||
|
|
||||||
|
|
@@ -18,51 +17,42 @@ export interface AlertDialogContentProps | |||||
| showNestedAnimation?: boolean; | ||||||
| } | ||||||
|
|
||||||
| export const AlertDialogContent = forwardRef< | ||||||
| ElementRef<typeof AlertDialogPrimitive.Popup>, | ||||||
| AlertDialogContentProps | ||||||
| >( | ||||||
| ( | ||||||
| { | ||||||
| className, | ||||||
| children, | ||||||
| showCloseButton = true, | ||||||
| overlay, | ||||||
| width, | ||||||
| style, | ||||||
| showNestedAnimation = true, | ||||||
| ...props | ||||||
| }, | ||||||
| ref | ||||||
| ) => { | ||||||
| return ( | ||||||
| <AlertDialogPrimitive.Portal> | ||||||
| <AlertDialogPrimitive.Backdrop | ||||||
| {...overlay} | ||||||
| export const AlertDialogContent = ({ | ||||||
| className, | ||||||
| children, | ||||||
| showCloseButton = true, | ||||||
| overlay, | ||||||
| width, | ||||||
| style, | ||||||
| showNestedAnimation = true, | ||||||
| ...props | ||||||
| }: AlertDialogContentProps) => { | ||||||
| return ( | ||||||
| <AlertDialogPrimitive.Portal> | ||||||
| <AlertDialogPrimitive.Backdrop | ||||||
| {...overlay} | ||||||
| className={cx( | ||||||
| styles.dialogOverlay, | ||||||
| overlay?.blur && styles.overlayBlur, | ||||||
| overlay?.className | ||||||
| )} | ||||||
|
Comment on lines
+32
to
+38
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strip Line 33 spreads the full Proposed fix export const AlertDialogContent = ({
className,
children,
showCloseButton = true,
overlay,
width,
style,
showNestedAnimation = true,
...props
}: AlertDialogContentProps) => {
+ const {
+ blur: overlayBlur,
+ className: overlayClassName,
+ ...overlayProps
+ } = overlay ?? {};
+
return (
<AlertDialogPrimitive.Portal>
<AlertDialogPrimitive.Backdrop
- {...overlay}
+ {...overlayProps}
className={cx(
styles.dialogOverlay,
- overlay?.blur && styles.overlayBlur,
- overlay?.className
+ overlayBlur && styles.overlayBlur,
+ overlayClassName
)}
/>🤖 Prompt for AI Agents |
||||||
| /> | ||||||
| <AlertDialogPrimitive.Viewport className={styles.viewport}> | ||||||
| <AlertDialogPrimitive.Popup | ||||||
| className={cx( | ||||||
| styles.dialogOverlay, | ||||||
| overlay?.blur && styles.overlayBlur, | ||||||
| overlay?.className | ||||||
| styles.dialogContent, | ||||||
| showNestedAnimation && styles.showNestedAnimation, | ||||||
| className | ||||||
| )} | ||||||
| /> | ||||||
| <AlertDialogPrimitive.Viewport className={styles.viewport}> | ||||||
| <AlertDialogPrimitive.Popup | ||||||
| ref={ref} | ||||||
| className={cx( | ||||||
| styles.dialogContent, | ||||||
| showNestedAnimation && styles.showNestedAnimation, | ||||||
| className | ||||||
| )} | ||||||
| style={{ width, ...style }} | ||||||
| {...props} | ||||||
| > | ||||||
| {children} | ||||||
| {showCloseButton && <CloseButton className={styles.closeButton} />} | ||||||
| </AlertDialogPrimitive.Popup> | ||||||
| </AlertDialogPrimitive.Viewport> | ||||||
| </AlertDialogPrimitive.Portal> | ||||||
| ); | ||||||
| } | ||||||
| ); | ||||||
| style={{ width, ...style }} | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let the explicit Line 47 currently uses Proposed fix- style={{ width, ...style }}
+ style={width === undefined ? style : { ...style, width }}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| {...props} | ||||||
| > | ||||||
| {children} | ||||||
| {showCloseButton && <CloseButton className={styles.closeButton} />} | ||||||
| </AlertDialogPrimitive.Popup> | ||||||
| </AlertDialogPrimitive.Viewport> | ||||||
| </AlertDialogPrimitive.Portal> | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| AlertDialogContent.displayName = 'AlertDialog.Content'; | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For@base-ui/reactAccordion, is an empty string ("") a valid item value? Please link official docs/API reference.💡 Result:
Yes. In @base-ui/react Accordion,
Accordion.Item’svalueprop is typed asanyand is described as “a unique value that identifies this accordion item.” An empty string ("") is still a (string) value, so it’s valid as long as it’s unique among items. If you omitvalueentirely, Base UI will generate an ID instead. [1]Official docs / API reference:
Accordion.Item valueprop table): https://base-ui.com/react/components/accordion [1]Related note (initially-open behavior requires an explicit
value):Sources: [1] https://base-ui.com/react/components/accordion, [2] https://base-ui.com/react/overview/releases/v1-0-0-beta-4
🏁 Script executed:
Repository: raystack/apsara
Length of output: 118
🏁 Script executed:
Repository: raystack/apsara
Length of output: 1032
🏁 Script executed:
Repository: raystack/apsara
Length of output: 747
🏁 Script executed:
Repository: raystack/apsara
Length of output: 524
Use explicit
!== undefinedchecks to preserve falsy values like empty strings.The truthy checks on lines 38 and 44 will incorrectly convert empty strings (
"") toundefined. Since@base-ui/reactAccordion accepts empty strings as valid item values, this causes silent data loss. Replacevalue ?withvalue !== undefinedanddefaultValue ?withdefaultValue !== undefined.Proposed patch
📝 Committable suggestion
🤖 Prompt for AI Agents