ant-design / ant-design/pro-components

๐Ÿ›[BUG] If table column header is nested, showListItemOption is not working

Open
#8,271 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
4.8k
Forks
1.4k
Avg merge
10h 44m
Merged PRs (30d)
3

Description

ๆ้—ฎๅ‰ๅ…ˆ็œ‹็œ‹๏ผš

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

### ๐Ÿ› bug ๆ่ฟฐ

if table has nested header , hiding nesting columns won't work

### ๐Ÿ“ท ๅค็Žฐๆญฅ้ชค

### ๐Ÿž ๆœŸๆœ›็ป“ๆžœ

![image](https://github.com/ant-design/pro-components/assets/64529155/23016ac6-0a7f-47ee-a130-61fbb2647a80)

### ๐Ÿ’ป ๅค็Žฐไปฃ็ 
columns looks like this and if there are no nested header, works propably
```
export const usePurchaseItemTableColumns = ({
getSellerEntity,
getUserEntity,
refresh,
setParams,
coinEntities,
}: {
getSellerEntity: (id: string) => Commerce.ISeller;
getUserEntity: (id: string) => Moim.IUser;
coinEntities: Record;
setParams: ((params: Record) => void) | undefined;
refresh: () => void;
}): React.ComponentProps>["columns"] => {
const intl = useIntlShort();
const currentGroup = useGroupStore((state) => state.currentGroup);
const hubSeller = useSellerStore((state) => state.hubSeller);
const isPickUpActivated = hubSeller.config?.pickUpEnabled;

return [
{
title: "table_column_title_order_number",
children: [
{
title: "table_column_title_payment_id",
render: (_, data) => {
if (!data?.paymentId) return "-";
return {data?.paymentId};
},
width: ColumnWidths.md,
},
{
title: "table_column_title_purchase_id",
render: (_, data) => {
if (!data?.purchaseId) return "-";
return {data?.purchaseId};
},
width: ColumnWidths.md,
},
{
title: "table_column_title_purchase_item_id",
dataIndex: "id",
width: ColumnWidths.md,
},
],
},
{
title: "table_column_title_purchase_date",
dataIndex: "createdAt",
valueType: "dateTime",
width: 150,
},
{
title: "table_column_title_paid_date",
children: [
{
title: "table_column_title_paid_date",
dataIndex: "paidAt",
valueType: "dateTime",
width: ColumnWidths.lg,
},
{
title: "table_column_title_after_paid",
render: (_, data) =>
data.paidAt ? `D+${Math.ceil((new Date().setHours(0, 0, 0, 0) - new Date(data.paidAt).setHours(0, 0, 0, 0)) / (1000 * 60 * 60 * 24))}` : "-",
width: ColumnWidths.sm,
},
],
},
{
title: "table_column_title_preparing_date",
children: [
{
title: "table_column_title_in_transit_date",
dataIndex: "shippedAt",
valueType: "dateTime",
width: ColumnWidths.lg,
},
{
title: "table_column_title_after_in_transit",
render: (_, data) =>
data.shippedAt ? `D+${Math.ceil((new Date().setHours(0, 0, 0, 0) - new Date(data.shippedAt).setHours(0, 0, 0, 0)) / (1000 * 60 * 60 * 24))}` : "-",
width: ColumnWidths.sm,
},
],
},
...(isPickUpActivated
? [
{
title: "table_column_title_visit_date",
render: (_: React.ReactNode, data: Commerce.IPurchaseItem) => {
return formatDateTime(data.pickUpTime);
},
width: ColumnWidths.lg,
},
]
: []),
{
title: "table_column_title_delivery_date",
children: [
{
title: "table_column_title_payment_times",
render: (_, entity) =>
entity.purchase?.isGuestCheckout || !entity?.purchase?.userId ? (
"-"
) : (

{
setParams?.({
userIds: [entity.purchase.userId],
});
}}
>
{entity.paidOrder ?? entity.purchase.payment?.order ?? "-"}


),
width: ColumnWidths.lg,
},
...(hubSeller?.config?.guestCheckoutEnabled
? [
{
title: "table_column_title_buyer_type",
render: (_: React.ReactNode, data: Commerce.IPurchaseItem) =>
data?.purchase?.isGuestCheckout ? intl("buyer_type_guest") : intl("buyer_type_member"),
width: ColumnWidths.lg,
},
]
: []),
{
title: "table_column_title_username",
render: (_, data) =>
data?.purchase?.isGuestCheckout || !data?.purchase?.userId ? (
data?.purchase?.buyerName ?? "-"
) : (

{getUserEntity(data.userId)?.name ?? data?.purchase.username}

),
width: ColumnWidths.lg,
},
...(currentGroup.config.enableWeb3
? [
{
title: "table_column_title_user_main_wallet_address",
render: (_: React.ReactNode, entity: Commerce.IPurchaseItem) => getUserEntity(entity.userId)?.metamask,
width: ColumnWidths.xxl,
},
]
: []),
{
title: "table_column_title_buyer_name",
render: (_, data) => data?.purchase?.buyerName ?? "-",
width: ColumnWidths.lg,
},
{
title: "table_column_title_phone_number",
render: (_, data) => `${data?.purchase?.buyerPhoneInfo?.countryCode ?? ""} ${data?.purchase?.buyerPhoneInfo?.nationalNumber ?? ""}`,
width: ColumnWidths.lg,
},
{
title: "table_column_title_email",
render: (_, data) => data?.purchase?.buyerEmail ?? "-",
width: ColumnWidths.lg,
},
],
},
{
title: "table_column_title_recipient",
render: (_, data) => data?.purchase?.recipientName ?? "-",
width: ColumnWidths.lg,
},
{
title: "table_column_title_product_info",
children: [
{
title: "table_column_title_product_name",
dataIndex: "productName",
width: ColumnWidths.xxl,
},
{
title: "table_column_title_sku",
render: (_, data) => data?.snap?.sku ?? "-",
width: ColumnWidths.lg,
},
{
title: "table_column_title_seller_name",
render: (_, data) => getSellerEntity(data.sellerId)?.name,
width: ColumnWidths.lg,
},
...(hubSeller.config?.brandEnabled
? [
{
title: "table_column_title_brand",
render: (_: ReactNode, data: Commerce.IPurchaseItem) => data?.snap?.brand?.name ?? "-",
width: ColumnWidths.lg,
},
]
: []),
{
title: "table_column_title_shipping_option",
render: (_, data) => {
const deliveryPolicy = data.deliveryGroup?.policy;

if (deliveryPolicy) {
return (


{deliveryPolicy.name ?? deliveryPolicy.id}
{deliveryPolicy.description && {deliveryPolicy.description}}

);
}
return "-";
},
width: ColumnWidths.xxl,
},
],
},
{
title: "table_column_title_order_info",
children: [
...(hubSeller?.config?.backOrderEnabled
? [
{
title: "table_column_title_with_backorder",
render: (_: React.ReactNode, entity: Commerce.IPurchaseItem) => (entity?.isBackOrder ? "O" : "X"),
width: ColumnWidths.lg,
},
]
: []),
{
title: "table_column_title_product_quantity",
dataIndex: "productCount",
width: ColumnWidths.xs,
},
{
title: "table_column_title_product_purchase_price",
render: (_, data) => (
({ ...fee, amount: fee.amount * data.quantity }))}
coinEntities={coinEntities}
/>
),
width: ColumnWidths.md,
},
{
title: "table_column_title_purchase_status",
width: ColumnWidths.lg,
render: (_, data) => {
return getPurchaseStatusDisplay(data.displayingStatus, intl, {
forItem: true,
shippingRequired: data.deliveryType !== "noDelivery",
});
},
},
{
title: "table_column_title_delivery_id",
render: (_, data) => {
if (data.deliveryType === "noDelivery") return null;
return ;
},
width: ColumnWidths.xxl,
},
...(hubSeller?.customStatusDefinition
? [
{
title: "table_column_title_custom_status",
render: (_: React.ReactNode, data: Commerce.IPurchaseItem) => {
const customStatus = data.customStatus;
if (!customStatus || !hubSeller?.customStatusDefinition) {
return -;
}
return {hubSeller.customStatusDefinition[customStatus]?.[browserLocale()] ?? "-"};
},
width: ColumnWidths.xxl,
},
]
: []),
{
title: "table_column_title_seller_updates",
render: (_, data) => {
if (!data.customButtons?.length) {
return "-";
}

const link = data.customButtons[data.customButtons.length - 1]?.link;

try {
new URL(link);

return (

{link}

);
} catch {
if (link?.startsWith("/")) {
return (

{link}

);
}

return "-";
}
},
width: ColumnWidths.xxl,
},
],
},
];
};
```

### ยฉ ็‰ˆๆœฌไฟกๆฏ

- ProComponents ็‰ˆๆœฌ: [5.15.3]
- ๅผ€ๅ‘็Žฏๅขƒ [mac OS]

### ๐Ÿš‘ ๅ…ถไป–ไฟกๆฏ

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue in the provided ProComponents table column definition, focusing on showListItemOption with nested children columns. Compare the behavior with a flat column list; the work is done when hiding a nested child column works as it does for non-nested columns.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.