Skip to content

Commit

Permalink
fix: warnings on React 19 (#7654)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan authored Oct 22, 2024
1 parent 5452e3d commit 9c72c74
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dev/test-next-studio/next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
14 changes: 11 additions & 3 deletions packages/sanity/src/core/components/commandList/CommandList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {throttle} from 'lodash'
import {
cloneElement,
forwardRef,
Fragment,
isValidElement,
type ReactElement,
useCallback,
useEffect,
Expand Down Expand Up @@ -612,9 +614,14 @@ export const CommandList = forwardRef<CommandListHandle, CommandListProps>(funct
virtualIndex,
}) as ReactElement

const clonedItem = cloneElement(itemToRender, {
tabIndex: -1,
})
const clonedItem = cloneElement(
itemToRender,
isValidElement(itemToRender) && itemToRender.type == Fragment
? {}
: {
tabIndex: -1,
},
)

const activeAriaAttributes =
typeof activeIndex === 'number' && !disabled
Expand Down Expand Up @@ -655,3 +662,4 @@ export const CommandList = forwardRef<CommandListHandle, CommandListProps>(funct
</VirtualListBox>
)
})
CommandList.displayName = 'ForwardRef(CommandList)'
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function SubSection({subSection}: {subSection: Section}) {
case 'internalAction': // TODO: Add support for internal actions (MVI-2)
if (!item.type) return null
if (item.type === 'studio-announcements-modal')
return <StudioAnnouncementsMenuItem text={item.title} />
return <StudioAnnouncementsMenuItem key={item._key} text={item.title} />
return (
item.type === 'show-welcome-modal' && <MenuItem key={item._key} text={item.title} />
)
Expand Down

0 comments on commit 9c72c74

Please sign in to comment.