Skip to content

fix(S2): inert value and img empty src string in React 19 #8359

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

Merged
merged 5 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions packages/@react-spectrum/s2/chromatic/CardView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,17 @@ const meta: Meta<typeof CardView> = {
export default meta;

const cardViewStyles = style({
width: {
default: 'screen',
viewMode: {
docs: 'full'
}
},
height: {
default: 'screen',
viewMode: {
docs: 600
}
}
width: 'screen',
maxWidth: 'full',
height: 600
});

export const Empty = (args: CardViewProps<any>, {viewMode}) => {
export const Empty = (args: CardViewProps<any>) => {
return (
<CardView
aria-label="Assets"
{...args}
styles={cardViewStyles({viewMode})}
styles={cardViewStyles}
renderEmptyState={() => (
<IllustratedMessage size="L">
<EmptyIcon />
Expand Down
2 changes: 1 addition & 1 deletion packages/@react-spectrum/s2/src/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export const Image = forwardRef(function Image(props: ImageProps, domRef: Forwar
{!errorState && (
<img
{...getFetchPriorityProp(fetchPriority)}
src={src}
src={src || undefined}
alt={alt}
crossOrigin={crossOrigin}
decoding={decoding}
Expand Down
3 changes: 2 additions & 1 deletion packages/@react-spectrum/s2/src/Skeleton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ export function SkeletonWrapper({children}: {children: SkeletonElement}): ReactN
{isLoading ? cloneElement(children, {
ref: mergeRefs(childRef, animation),
className: (children.props.className || '') + ' ' + loadingStyle,
inert: 'true'
// @ts-ignore - compatibility with React < 19
inert: inertValue(true)
}) : children}
</SkeletonContext.Provider>
);
Expand Down
27 changes: 9 additions & 18 deletions packages/@react-spectrum/s2/stories/CardView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,9 @@ const meta: Meta<typeof CardView> = {
export default meta;

const cardViewStyles = style({
width: {
default: 'screen',
viewMode: {
docs: 'full'
}
},
height: {
default: 'screen',
viewMode: {
docs: 600
}
}
width: 'screen',
maxWidth: 'full',
height: 600
});

type Item = {
Expand Down Expand Up @@ -101,7 +92,7 @@ function PhotoCard({item, layout}: {item: Item, layout: string}) {
);
}

export const Example = (args: CardViewProps<any>, {viewMode}) => {
export const Example = (args: CardViewProps<any>) => {
let list = useAsyncList<Item, number | null>({
async load({signal, cursor, items}) {
let page = cursor || 1;
Expand All @@ -126,7 +117,7 @@ export const Example = (args: CardViewProps<any>, {viewMode}) => {
{...args}
loadingState={loadingState}
onLoadMore={args.loadingState === 'idle' ? list.loadMore : undefined}
styles={cardViewStyles({viewMode})}>
styles={cardViewStyles}>
<Collection items={items} dependencies={[args.layout]}>
{item => <PhotoCard item={item} layout={args.layout || 'grid'} />}
</Collection>
Expand Down Expand Up @@ -157,12 +148,12 @@ Example.args = {
selectionMode: 'multiple'
};

export const Empty = (args: CardViewProps<any>, {viewMode}) => {
export const Empty = (args: CardViewProps<any>) => {
return (
<CardView
aria-label="Assets"
{...args}
styles={cardViewStyles({viewMode})}
styles={cardViewStyles}
renderEmptyState={() => (
<IllustratedMessage size="L">
<EmptyIcon />
Expand Down Expand Up @@ -202,7 +193,7 @@ function TopicCard({topic}: {topic: Topic}) {
);
}

export const CollectionCards = (args: CardViewProps<any>, {viewMode}) => {
export const CollectionCards = (args: CardViewProps<any>) => {
let list = useAsyncList<Topic, number | null>({
async load({signal, cursor}) {
let page = cursor || 1;
Expand All @@ -224,7 +215,7 @@ export const CollectionCards = (args: CardViewProps<any>, {viewMode}) => {
{...args}
loadingState={loadingState}
onLoadMore={args.loadingState === 'idle' ? list.loadMore : undefined}
styles={cardViewStyles({viewMode})}>
styles={cardViewStyles}>
<Collection items={items}>
{topic => <TopicCard topic={topic} />}
</Collection>
Expand Down
3 changes: 2 additions & 1 deletion packages/react-aria-components/src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ export const TabPanel = /*#__PURE__*/ createHideableComponent(function TabPanel(
values: {
isFocused,
isFocusVisible,
isInert: !isSelected,
// @ts-ignore - compatibility with React < 19
isInert: inertValue(!isSelected),
state
}
});
Expand Down