Skip to content
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

Add extra check for sidebar item type #4065

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 7 additions & 0 deletions .changeset/little-avocados-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@toptal/picasso': patch
---

### SidebarMenu

- add extra check for sidebar item type
4 changes: 2 additions & 2 deletions packages/picasso/src/SidebarMenu/SidebarMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { forwardRef, useCallback, useEffect } from 'react'
import Menu from '../Menu'
import { useSidebarContext } from '../PageSidebar/SidebarContextProvider'
import type { SidebarItemProps } from '../SidebarItem'
import { useSubMenuContext } from '../SidebarItem'
import SidebarItem, { useSubMenuContext } from '../SidebarItem'
import styles from './styles'

export interface Props extends BaseProps, HTMLAttributes<HTMLUListElement> {
Expand Down Expand Up @@ -50,7 +50,7 @@ export const SidebarMenu = forwardRef<HTMLUListElement, Props>(
}, [parentSidebarItemIndex, setExpandedItemKey, children])

const items = React.Children.map(children, (child, index) => {
if (React.isValidElement(child)) {
if (React.isValidElement(child) && child.type === SidebarItem) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think, it's kinda a strict requirement, because, some components may be extended from SidebarItem. We may break tha backward compatibility

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

good point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it @dmaklygin 👍
For now, I don't see any other way to fix it, I will close the PR.

const itemProps: Partial<SidebarItemProps> = {
variant,
isSubMenu,
Expand Down
Loading