Skip to content

Commit

Permalink
[FX-5974] Fix disabled state when compact and collapsible
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasSlama committed Sep 19, 2024
1 parent d5027ed commit ebe62a1
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/curly-mails-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@toptal/picasso-dropdown': minor
'@toptal/picasso': minor
---

### Dropdown

- support disabled state
8 changes: 8 additions & 0 deletions .changeset/four-drinks-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@toptal/picasso-page': patch
'@toptal/picasso': patch
---

### PageSidebar

- fix disabled state for collapsible compact sidebar item
10 changes: 8 additions & 2 deletions packages/base/Dropdown/src/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ interface InternalProps
content: ReactNode
/** The placement of the content element relative to anchor element. */
placement?: PopperPlacementType
/** Disabled */
disabled?: boolean
/** Disable auto focus of first item in list or item */
disableAutoFocus?: boolean
/** Disable close on generic close events */
Expand Down Expand Up @@ -131,6 +133,7 @@ export const Dropdown: DropdownProps = forwardRef<
content,
offset,
placement,
disabled,
disableAutoClose,
disableAutoFocus,
disablePortal,
Expand Down Expand Up @@ -258,8 +261,11 @@ export const Dropdown: DropdownProps = forwardRef<
style={style}
>
<div
className='inline-flex items-center cursor-pointer'
onClick={handleAnchorClick}
className={twJoin(
'inline-flex items-center',
disabled ? 'pointer-events-none' : 'cursor-pointer'
)}
onClick={disabled ? () => {} : handleAnchorClick}
>
{typeof children === 'function' ? children({ isOpen }) : children}
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/base/Page/src/SidebarItem/SidebarItemCompact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const useStyles = makeStyles<Theme>(styles, {

export const SidebarItemCompact = forwardRef<HTMLElement, Props>(
function CompactSidebarItem(props: Props, ref) {
const { menu, index, compact, icon } = props
const { menu, index, compact, icon, disabled } = props
const [isOpened, handleOpen, handleClose] = useOpen()
const classes = useStyles()

Expand All @@ -35,6 +35,7 @@ export const SidebarItemCompact = forwardRef<HTMLElement, Props>(
<Container left='small' right='small'>
<Dropdown
classes={{ popper: classes.compactDropdown }}
disabled={disabled}
placement='right-start'
content={subMenu}
keepMounted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const Menu = () => (
<Page.Sidebar.Item
collapsible
icon={<AddDocument16 />}
disabled
menu={
<Page.Sidebar.Menu>
<Page.Sidebar.Item badge={5} tag='New'>
Expand Down

0 comments on commit ebe62a1

Please sign in to comment.