Skip to content

Conversation

@devongovett
Copy link
Member

Fixes regressions introduced in #8327. ColorArea and ColorSwatch had their prop merge order changed which broke in chromatic. Also omitting DOM attributes from S2 for now. This was causing storybook controls to crash.

}

let childRef = 'ref' in children ? children.ref as any : children.props.ref;
let childRef = 'ref' in children && !Object.getOwnPropertyDescriptor(children, 'ref')?.get ? children.ref as any : children.props.ref;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes crash in storybook in React 19. React emits a warning when accessing element.ref. This checks if that is defined as a getter.

@rspbot
Copy link

rspbot commented Jul 10, 2025

@rspbot
Copy link

rspbot commented Jul 10, 2025

## API Changes

@react-spectrum/s2

/@react-spectrum/s2:ComboBoxSection

 ComboBoxSection <T extends {}> {
   aria-label?: string
-  children?: ReactNode | ({}) => ReactElement
+  children?: ReactNode | (T) => ReactElement
   className?: string
   dependencies?: ReadonlyArray<any>
   id?: Key
-  items?: Iterable<{}>
+  items?: Iterable<T>
   style?: CSSProperties
-  value?: {}
+  value?: T
 }

/@react-spectrum/s2:MenuSection

 MenuSection <T extends {}> {
   aria-label?: string
-  children?: ReactNode | ({}) => ReactElement
+  children?: ReactNode | (T) => ReactElement
   className?: string
   defaultSelectedKeys?: 'all' | Iterable<Key>
   dependencies?: ReadonlyArray<any>
   disabledKeys?: Iterable<Key>
   disallowEmptySelection?: boolean
   id?: Key
-  items?: Iterable<{}>
+  items?: Iterable<T>
   onSelectionChange?: (Selection) => void
   selectedKeys?: 'all' | Iterable<Key>
   selectionMode?: SelectionMode
   style?: CSSProperties
-  value?: {}
+  value?: T
 }

/@react-spectrum/s2:PickerSection

 PickerSection <T extends {}> {
   aria-label?: string
-  children?: ReactNode | ({}) => ReactElement
+  children?: ReactNode | (T) => ReactElement
   className?: string
   dependencies?: ReadonlyArray<any>
   id?: Key
-  items?: Iterable<{}>
+  items?: Iterable<T>
   style?: CSSProperties
-  value?: {}
+  value?: T
 }

/@react-spectrum/s2:ComboBoxSectionProps

 ComboBoxSectionProps <T extends {}> {
   aria-label?: string
-  children?: ReactNode | ({}) => ReactElement
+  children?: ReactNode | (T) => ReactElement
   className?: string
   dependencies?: ReadonlyArray<any>
   id?: Key
-  items?: Iterable<{}>
+  items?: Iterable<T>
   style?: CSSProperties
-  value?: {}
+  value?: T
 }

/@react-spectrum/s2:MenuSectionProps

 MenuSectionProps <T extends {}> {
   aria-label?: string
-  children?: ReactNode | ({}) => ReactElement
+  children?: ReactNode | (T) => ReactElement
   className?: string
   defaultSelectedKeys?: 'all' | Iterable<Key>
   dependencies?: ReadonlyArray<any>
   disabledKeys?: Iterable<Key>
   disallowEmptySelection?: boolean
   id?: Key
-  items?: Iterable<{}>
+  items?: Iterable<T>
   onSelectionChange?: (Selection) => void
   selectedKeys?: 'all' | Iterable<Key>
   selectionMode?: SelectionMode
   style?: CSSProperties
-  value?: {}
+  value?: T
 }

/@react-spectrum/s2:PickerSectionProps

 PickerSectionProps <T extends {}> {
   aria-label?: string
-  children?: ReactNode | ({}) => ReactElement
+  children?: ReactNode | (T) => ReactElement
   className?: string
   dependencies?: ReadonlyArray<any>
   id?: Key
-  items?: Iterable<{}>
+  items?: Iterable<T>
   style?: CSSProperties
-  value?: {}
+  value?: T
 }

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to get in and we can discuss the order without chromatic crashing

return (
<div
{...mergeProps(DOMProps, renderProps, colorSwatchProps)}
{...mergeProps(DOMProps, colorSwatchProps, renderProps)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's opposite order in other components, ie ProgressBar
Are these special cases? or should they all be in this order?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's because useColorSwatch returns style, and that gets passed into useRenderProps as defaultStyle, so the user can override it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha, should the others be flipped then as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked all the hooks that return styles. I think flipping the order by default would not be enough, because the defaultStyle would have to be passed into useRenderProps anyway.

@devongovett devongovett added this pull request to the merge queue Jul 10, 2025
Merged via the queue into main with commit 01275a9 Jul 10, 2025
31 checks passed
@devongovett devongovett deleted the fix-dom-events branch July 10, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants