Skip to content

fix: Add an indicator for disabled ActionList items (e.g. in a SelectPanel) #6246

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/true-parents-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

Disabled ActionList items now have a visible indicator when hovered or selected.
15 changes: 15 additions & 0 deletions packages/react/src/ActionList/ActionList.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,21 @@
}
}
}

&:where([data-active]),
&:where([data-is-active-descendant]) {
background: transparent;

/* provides a visual indication of the current item for Windows high-contrast mode */
outline: 2px solid var(--control-transparent-bgColor-selected);
Comment on lines +346 to +349
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
background: transparent;
/* provides a visual indication of the current item for Windows high-contrast mode */
outline: 2px solid var(--control-transparent-bgColor-selected);
background: var(--control-transparent-bgColor-disabled);

I wonder if this might look a little cleaner? Just guessing, I haven't tried it


/* gray accent line */
&::after {
@mixin activeIndicatorLine;
/* stylelint-disable-next-line primer/colors */
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/* stylelint-disable-next-line primer/colors */

background: var(--fgColor-muted);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
background: var(--fgColor-muted);
background: var(--bgColor-neutral-emphasis);

}
}
}

/* Make sure that the first visible item isn't a divider */
Expand Down
37 changes: 37 additions & 0 deletions packages/react/src/SelectPanel/SelectPanel.features.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -853,3 +853,40 @@ export const WithInactiveItems = () => {
</FormControl>
)
}

export const WithDisabledItems = () => {
const itemsWithDisabled = items.map<Items>((item: Items, index: number) => ({
...item,
disabled: index === 4 ? true : item.disabled,
}))

const [selected, setSelected] = useState<ItemInput[]>(itemsWithDisabled.slice(1, 3))
const [filter, setFilter] = useState('')
const filteredItems = itemsWithDisabled.filter(item => item.text?.toLowerCase().startsWith(filter.toLowerCase()))

const [open, setOpen] = useState(false)

return (
<FormControl>
<FormControl.Label>Labels</FormControl.Label>
<SelectPanel
title="Select labels"
placeholder="Select labels" // button text when no items are selected
subtitle="Use labels to organize issues and pull requests"
renderAnchor={({children, ...anchorProps}) => (
<Button trailingAction={TriangleDownIcon} {...anchorProps} aria-haspopup="dialog">
{children}
</Button>
)}
open={open}
onOpenChange={setOpen}
items={filteredItems}
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
width="medium"
message={filteredItems.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
)
}
Loading