Skip to content

fix(S2): React 19 and storybook fixes #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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
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
25 changes: 20 additions & 5 deletions packages/@react-spectrum/s2/stories/CardView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ function PhotoCard({item, layout}: {item: Item, layout: string}) {
);
}

export const Example = (args: CardViewProps<any>, {viewMode}) => {
export const Example = (args: CardViewProps<any> & {viewMode: string}) => {
let {viewMode} = args;
let list = useAsyncList<Item, number | null>({
async load({signal, cursor, items}) {
let page = cursor || 1;
Expand Down Expand Up @@ -154,10 +155,14 @@ export const Example = (args: CardViewProps<any>, {viewMode}) => {
Example.args = {
loadingState: 'idle',
onAction: null,
selectionMode: 'multiple'
selectionMode: 'multiple',
decorators: [
(Story, {viewMode}) => <Story viewMode={viewMode} />
Copy link
Member

Choose a reason for hiding this comment

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

Can you add this in the ActionBar example with CardView too? Looks like it's horizontally scrolling at the moment

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like viewMode isn't actually making it into the story from the decorator, so I need to fix that first.

Copy link
Member

Choose a reason for hiding this comment

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

I've been poking around locally, the viewMode doesn't seem to have been working for quite some time actually, regardless if you run the storybook in docs mode or not. Still bisecting

Copy link
Member

Choose a reason for hiding this comment

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

Apparently something from #7435? Thats when viewMode becomes undefined for me locally but nothing in the PR jumps out to me

]
};

export const Empty = (args: CardViewProps<any>, {viewMode}) => {
export const Empty = (args: CardViewProps<any> & {viewMode: string}) => {
let {viewMode} = args;
return (
<CardView
aria-label="Assets"
Expand All @@ -175,6 +180,12 @@ export const Empty = (args: CardViewProps<any>, {viewMode}) => {
);
};

Empty.args = {
decorators: [
(Story, {viewMode}) => <Story viewMode={viewMode} />
]
};

interface Topic {
id: string,
title: string,
Expand Down Expand Up @@ -202,7 +213,8 @@ function TopicCard({topic}: {topic: Topic}) {
);
}

export const CollectionCards = (args: CardViewProps<any>, {viewMode}) => {
export const CollectionCards = (args: CardViewProps<any> & {viewMode: string}) => {
let {viewMode} = args;
let list = useAsyncList<Topic, number | null>({
async load({signal, cursor}) {
let page = cursor || 1;
Expand Down Expand Up @@ -253,5 +265,8 @@ export const CollectionCards = (args: CardViewProps<any>, {viewMode}) => {

CollectionCards.args = {
loadingState: 'idle',
onAction: null
onAction: null,
decorators: [
(Story, {viewMode}) => <Story viewMode={viewMode} />
]
};
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