Skip to content

Commit

Permalink
fix: Allows triggers on dropdown and fixes filtering (unkeyed#2748)
Browse files Browse the repository at this point in the history
* Fix button triggers

Remove asChild to allow trigger from buttons

* remove as child

Removing as child to allow for correct triggers

* Fix filtering

Fix filter to work as expected

---------

Co-authored-by: James Perkins <jamesperkins@Jamess-MacBook-Air.local>
  • Loading branch information
perkinsjr and James Perkins authored Dec 13, 2024
1 parent 580c165 commit 74f8359
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 12 deletions.
5 changes: 2 additions & 3 deletions apps/dashboard/app/(app)/audit/[bucket]/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const Filter: React.FC<Props> = ({ options, title, param }) => {

return (
<Popover>
<PopoverTrigger asChild>
<PopoverTrigger>
<Button className="flex items-center h-8 gap-2 ">
{title}
{selected.length > 0 && (
Expand Down Expand Up @@ -70,10 +70,9 @@ export const Filter: React.FC<Props> = ({ options, title, param }) => {
<CommandGroup>
{options.map((option) => {
const isSelected = selected.includes(option.value);

return (
<div
onMouseDownCapture={() => {
onClick={() => {
const next = isSelected
? selected.filter((v) => v !== option.value)
: Array.from(new Set([...selected, option.value]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const Filters: React.FC = () => {
<div className="flex flex-col w-full gap-2">
<div className="flex items-center justify-end w-full gap-2">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button className="text-xs">
Add Filter <ChevronDown className="w-4 h-4" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const Menu: React.FC<Props> = ({ namespace, identifier }) => {

return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button variant="ghost" shape="square">
<MoreHorizontal className="w-4 h-4" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const UpdateUserEmail: React.FC = () => {

<TableCell align="right">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button variant="ghost">
<MoreHorizontal className="w-4 h-4" />
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export const ApiKeyTable: React.FC<Props> = ({ data }) => {
<div>
<Dialog>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button variant="ghost" className="w-8 h-8 p-0">
<span className="sr-only">Open menu</span>
<MoreHorizontal className="w-4 h-4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function DataTable<TData, TValue>({ data, columns }: DataTableProps<TData
className="max-w-sm md:max-w-2xl"
/>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button className="min-w-full mt-4 ml-0 md:min-w-min md:mt-0 md:ml-auto">
Columns
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const RootKeyTable: React.FC<Props> = ({ data }) => {
<div>
<Dialog>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button variant="ghost" className="w-8 h-8 p-0">
<span className="sr-only">Open menu</span>
<MoreHorizontal className="w-4 h-4" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function DataTable<TData, TValue>({ data, columns }: DataTableProps<TData
className="max-w-sm md:max-w-2xl"
/>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button className="min-w-full mt-4 ml-0 md:min-w-min md:mt-0 md:ml-auto">
Columns
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/components/data-table/column-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function DataTableColumnHeader<TData, TValue>({
return (
<div className={cn("flex items-center space-x-2", className)}>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button variant="ghost" className="h-8 -ml-3">
<span>{title}</span>
{column.getIsSorted() === "desc" ? (
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/components/data-table/view-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface DataTableViewOptionsProps<TData> {
export function DataTableViewOptions<TData>({ table }: DataTableViewOptionsProps<TData>) {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button className="hidden h-8 ml-auto lg:flex">
<ListFilter className="w-4 h-4 mr-2" />
View
Expand Down

0 comments on commit 74f8359

Please sign in to comment.