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

[FX-5974] Fix disabled state when compact and collapsible #4568

Merged
merged 1 commit into from
Sep 20, 2024
Merged
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
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
Loading