Skip to content

Commit 90f8432

Browse files
fix(S2): inert value and img empty src string in React 19 (#8359)
* fix viewMode error in CardView stories * fix inert values for react 19 * fix empty src string error * Revert "fix viewMode error in CardView stories" This reverts commit 05f0459. * remove use of viewMode --------- Co-authored-by: Robert Snow <[email protected]>
1 parent 04462ef commit 90f8432

File tree

5 files changed

+19
-35
lines changed

5 files changed

+19
-35
lines changed

packages/@react-spectrum/s2/chromatic/CardView.stories.tsx

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,17 @@ const meta: Meta<typeof CardView> = {
2727
export default meta;
2828

2929
const cardViewStyles = style({
30-
width: {
31-
default: 'screen',
32-
viewMode: {
33-
docs: 'full'
34-
}
35-
},
36-
height: {
37-
default: 'screen',
38-
viewMode: {
39-
docs: 600
40-
}
41-
}
30+
width: 'screen',
31+
maxWidth: 'full',
32+
height: 600
4233
});
4334

44-
export const Empty = (args: CardViewProps<any>, {viewMode}) => {
35+
export const Empty = (args: CardViewProps<any>) => {
4536
return (
4637
<CardView
4738
aria-label="Assets"
4839
{...args}
49-
styles={cardViewStyles({viewMode})}
40+
styles={cardViewStyles}
5041
renderEmptyState={() => (
5142
<IllustratedMessage size="L">
5243
<EmptyIcon />

packages/@react-spectrum/s2/src/Image.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export const Image = forwardRef(function Image(props: ImageProps, domRef: Forwar
228228
{!errorState && (
229229
<img
230230
{...getFetchPriorityProp(fetchPriority)}
231-
src={src}
231+
src={src || undefined}
232232
alt={alt}
233233
crossOrigin={crossOrigin}
234234
decoding={decoding}

packages/@react-spectrum/s2/src/Skeleton.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ export function SkeletonWrapper({children}: {children: SkeletonElement}): ReactN
126126
{isLoading ? cloneElement(children, {
127127
ref: mergeRefs(childRef, animation),
128128
className: (children.props.className || '') + ' ' + loadingStyle,
129-
inert: 'true'
129+
// @ts-ignore - compatibility with React < 19
130+
inert: inertValue(true)
130131
}) : children}
131132
</SkeletonContext.Provider>
132133
);

packages/@react-spectrum/s2/stories/CardView.stories.tsx

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,9 @@ const meta: Meta<typeof CardView> = {
2929
export default meta;
3030

3131
const cardViewStyles = style({
32-
width: {
33-
default: 'screen',
34-
viewMode: {
35-
docs: 'full'
36-
}
37-
},
38-
height: {
39-
default: 'screen',
40-
viewMode: {
41-
docs: 600
42-
}
43-
}
32+
width: 'screen',
33+
maxWidth: 'full',
34+
height: 600
4435
});
4536

4637
type Item = {
@@ -101,7 +92,7 @@ function PhotoCard({item, layout}: {item: Item, layout: string}) {
10192
);
10293
}
10394

104-
export const Example = (args: CardViewProps<any>, {viewMode}) => {
95+
export const Example = (args: CardViewProps<any>) => {
10596
let list = useAsyncList<Item, number | null>({
10697
async load({signal, cursor, items}) {
10798
let page = cursor || 1;
@@ -126,7 +117,7 @@ export const Example = (args: CardViewProps<any>, {viewMode}) => {
126117
{...args}
127118
loadingState={loadingState}
128119
onLoadMore={args.loadingState === 'idle' ? list.loadMore : undefined}
129-
styles={cardViewStyles({viewMode})}>
120+
styles={cardViewStyles}>
130121
<Collection items={items} dependencies={[args.layout]}>
131122
{item => <PhotoCard item={item} layout={args.layout || 'grid'} />}
132123
</Collection>
@@ -157,12 +148,12 @@ Example.args = {
157148
selectionMode: 'multiple'
158149
};
159150

160-
export const Empty = (args: CardViewProps<any>, {viewMode}) => {
151+
export const Empty = (args: CardViewProps<any>) => {
161152
return (
162153
<CardView
163154
aria-label="Assets"
164155
{...args}
165-
styles={cardViewStyles({viewMode})}
156+
styles={cardViewStyles}
166157
renderEmptyState={() => (
167158
<IllustratedMessage size="L">
168159
<EmptyIcon />
@@ -202,7 +193,7 @@ function TopicCard({topic}: {topic: Topic}) {
202193
);
203194
}
204195

205-
export const CollectionCards = (args: CardViewProps<any>, {viewMode}) => {
196+
export const CollectionCards = (args: CardViewProps<any>) => {
206197
let list = useAsyncList<Topic, number | null>({
207198
async load({signal, cursor}) {
208199
let page = cursor || 1;
@@ -224,7 +215,7 @@ export const CollectionCards = (args: CardViewProps<any>, {viewMode}) => {
224215
{...args}
225216
loadingState={loadingState}
226217
onLoadMore={args.loadingState === 'idle' ? list.loadMore : undefined}
227-
styles={cardViewStyles({viewMode})}>
218+
styles={cardViewStyles}>
228219
<Collection items={items}>
229220
{topic => <TopicCard topic={topic} />}
230221
</Collection>

packages/react-aria-components/src/Tabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ export const TabPanel = /*#__PURE__*/ createHideableComponent(function TabPanel(
300300
values: {
301301
isFocused,
302302
isFocusVisible,
303-
isInert: !isSelected,
303+
// @ts-ignore - compatibility with React < 19
304+
isInert: inertValue(!isSelected),
304305
state
305306
}
306307
});

0 commit comments

Comments
 (0)