Skip to content

Commit 9c72c74

Browse files
authored
fix: warnings on React 19 (#7654)
1 parent 5452e3d commit 9c72c74

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

dev/test-next-studio/next-env.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

packages/sanity/src/core/components/commandList/CommandList.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {throttle} from 'lodash'
44
import {
55
cloneElement,
66
forwardRef,
7+
Fragment,
8+
isValidElement,
79
type ReactElement,
810
useCallback,
911
useEffect,
@@ -612,9 +614,14 @@ export const CommandList = forwardRef<CommandListHandle, CommandListProps>(funct
612614
virtualIndex,
613615
}) as ReactElement
614616

615-
const clonedItem = cloneElement(itemToRender, {
616-
tabIndex: -1,
617-
})
617+
const clonedItem = cloneElement(
618+
itemToRender,
619+
isValidElement(itemToRender) && itemToRender.type == Fragment
620+
? {}
621+
: {
622+
tabIndex: -1,
623+
},
624+
)
618625

619626
const activeAriaAttributes =
620627
typeof activeIndex === 'number' && !disabled
@@ -655,3 +662,4 @@ export const CommandList = forwardRef<CommandListHandle, CommandListProps>(funct
655662
</VirtualListBox>
656663
)
657664
})
665+
CommandList.displayName = 'ForwardRef(CommandList)'

packages/sanity/src/core/studio/components/navbar/resources/ResourcesMenuItems.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function SubSection({subSection}: {subSection: Section}) {
9999
case 'internalAction': // TODO: Add support for internal actions (MVI-2)
100100
if (!item.type) return null
101101
if (item.type === 'studio-announcements-modal')
102-
return <StudioAnnouncementsMenuItem text={item.title} />
102+
return <StudioAnnouncementsMenuItem key={item._key} text={item.title} />
103103
return (
104104
item.type === 'show-welcome-modal' && <MenuItem key={item._key} text={item.title} />
105105
)

0 commit comments

Comments
 (0)