fix(design-system): filter/sorting menu error (#12309)
This commit is contained in:
1 parent
b868a4ef4d
commit
4f6362b1cb
3 files changed
+21
-7
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/ui": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(design-system): filter/sorting menu tooltip error
|
||||||
+4
-2
@@ -34,6 +34,9 @@ const DataTableFilterMenu = (props: DataTableFilterMenuProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Wrapper = props.tooltip ? Tooltip : React.Fragment
|
const Wrapper = props.tooltip ? Tooltip : React.Fragment
|
||||||
|
const wrapperProps = props.tooltip
|
||||||
|
? { content: props.tooltip, hidden: filterOptions.length === 0 }
|
||||||
|
: ({} as any)
|
||||||
|
|
||||||
if (instance.showSkeleton) {
|
if (instance.showSkeleton) {
|
||||||
return <DataTableFilterMenuSkeleton />
|
return <DataTableFilterMenuSkeleton />
|
||||||
@@ -41,7 +44,7 @@ const DataTableFilterMenu = (props: DataTableFilterMenuProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<Wrapper content={props.tooltip} hidden={filterOptions.length === 0}>
|
<Wrapper {...wrapperProps}>
|
||||||
<DropdownMenu.Trigger asChild disabled={filterOptions.length === 0}>
|
<DropdownMenu.Trigger asChild disabled={filterOptions.length === 0}>
|
||||||
<IconButton size="small">
|
<IconButton size="small">
|
||||||
<Funnel />
|
<Funnel />
|
||||||
@@ -71,4 +74,3 @@ const DataTableFilterMenuSkeleton = () => {
|
|||||||
|
|
||||||
export { DataTableFilterMenu }
|
export { DataTableFilterMenu }
|
||||||
export type { DataTableFilterMenuProps }
|
export type { DataTableFilterMenuProps }
|
||||||
|
|
||||||
+12
-5
@@ -1,7 +1,10 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import { useDataTableContext } from "@/blocks/data-table/context/use-data-table-context"
|
import { useDataTableContext } from "@/blocks/data-table/context/use-data-table-context"
|
||||||
import { DataTableColumn, DataTableSortableColumnDefMeta } from "@/blocks/data-table/types"
|
import {
|
||||||
|
DataTableColumn,
|
||||||
|
DataTableSortableColumnDefMeta,
|
||||||
|
} from "@/blocks/data-table/types"
|
||||||
import { DropdownMenu } from "@/components/dropdown-menu"
|
import { DropdownMenu } from "@/components/dropdown-menu"
|
||||||
import { IconButton } from "@/components/icon-button"
|
import { IconButton } from "@/components/icon-button"
|
||||||
import { Skeleton } from "@/components/skeleton"
|
import { Skeleton } from "@/components/skeleton"
|
||||||
@@ -67,10 +70,11 @@ const DataTableSortingMenu = (props: DataTableSortingMenuProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Wrapper = props.tooltip ? Tooltip : React.Fragment
|
const Wrapper = props.tooltip ? Tooltip : React.Fragment
|
||||||
|
const wrapperProps = props.tooltip ? { content: props.tooltip } : ({} as any)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<Wrapper content={props.tooltip}>
|
<Wrapper {...wrapperProps}>
|
||||||
<DropdownMenu.Trigger asChild>
|
<DropdownMenu.Trigger asChild>
|
||||||
<IconButton size="small">
|
<IconButton size="small">
|
||||||
<DescendingSorting />
|
<DescendingSorting />
|
||||||
@@ -124,7 +128,9 @@ const DataTableSortingMenu = (props: DataTableSortingMenuProps) => {
|
|||||||
DataTableSortingMenu.displayName = "DataTable.SortingMenu"
|
DataTableSortingMenu.displayName = "DataTable.SortingMenu"
|
||||||
|
|
||||||
function getSortLabel(column: DataTableColumn<any, unknown>) {
|
function getSortLabel(column: DataTableColumn<any, unknown>) {
|
||||||
const meta = column.columnDef.meta as DataTableSortableColumnDefMeta | undefined
|
const meta = column.columnDef.meta as
|
||||||
|
| DataTableSortableColumnDefMeta
|
||||||
|
| undefined
|
||||||
let headerValue: string | undefined = undefined
|
let headerValue: string | undefined = undefined
|
||||||
|
|
||||||
if (typeof column.columnDef.header === "string") {
|
if (typeof column.columnDef.header === "string") {
|
||||||
@@ -142,7 +148,9 @@ function getSortDescriptor(
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const meta = column.columnDef.meta as DataTableSortableColumnDefMeta | undefined
|
const meta = column.columnDef.meta as
|
||||||
|
| DataTableSortableColumnDefMeta
|
||||||
|
| undefined
|
||||||
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case "asc":
|
case "asc":
|
||||||
@@ -158,4 +166,3 @@ const DataTableSortingMenuSkeleton = () => {
|
|||||||
|
|
||||||
export { DataTableSortingMenu }
|
export { DataTableSortingMenu }
|
||||||
export type { DataTableSortingMenuProps }
|
export type { DataTableSortingMenuProps }
|
||||||
|
|
||||||
Reference in new issue
Block a user