From 56d2b7d57e447f46f630990b07c75f631f3ff619 Mon Sep 17 00:00:00 2001 From: aibayanyu20 Date: Tue, 1 Nov 2022 08:50:16 +0800 Subject: [PATCH 1/3] fix: fix table column data is passed into chlidren is undefined or null errorr --- components/table/hooks/useColumns.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/table/hooks/useColumns.tsx b/components/table/hooks/useColumns.tsx index 8aed4d259b..aab022e250 100644 --- a/components/table/hooks/useColumns.tsx +++ b/components/table/hooks/useColumns.tsx @@ -37,7 +37,7 @@ function fillSlots(columns: ColumnsType, contextSlots: R () => [column.title as any], ); } - if ('children' in cloneColumn) { + if ('children' in cloneColumn && Array.isArray(cloneColumn.children)) { cloneColumn.children = fillSlots(cloneColumn.children, contextSlots); } From 7afe62814a3bc69d6bd01df5c762a659c3a20866 Mon Sep 17 00:00:00 2001 From: aibayanyu20 Date: Sat, 13 Jan 2024 10:12:22 +0800 Subject: [PATCH 2/3] fix(notification): use hook notification console warning --- .../vc-notification/HookNotification.tsx | 48 ++++++++++--------- .../vc-notification/useNotification.tsx | 10 ++-- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/components/vc-notification/HookNotification.tsx b/components/vc-notification/HookNotification.tsx index 597589e823..737e9e8960 100644 --- a/components/vc-notification/HookNotification.tsx +++ b/components/vc-notification/HookNotification.tsx @@ -1,5 +1,5 @@ import type { CSSProperties } from 'vue'; -import { watch, computed, defineComponent, ref, TransitionGroup } from 'vue'; +import { shallowRef, computed, defineComponent, ref, TransitionGroup } from 'vue'; import type { NoticeProps } from './Notice'; import Notice from './Notice'; import type { CSSMotionProps } from '../_util/transition'; @@ -51,6 +51,7 @@ export interface NotificationInstance { destroy: () => void; add: (noticeProps: NoticeContent) => void; component: Notification; + setNotices: (notice: NotificationState) => void; } export interface HookNotificationProps { @@ -62,7 +63,7 @@ export interface HookNotificationProps { hashId?: string; // Hook Notification remove: (key: Key) => void; - notices: NotificationState; + // notices: NotificationState; getStyles?: (placement?: Placement) => CSSProperties; getClassName?: (placement?: Placement) => string; onAllRemoved?: VoidFunction; @@ -93,9 +94,26 @@ const Notification = defineComponent({ 'onAllRemoved', 'getContainer', ] as any, - setup(props, { attrs, slots }) { + setup(props, { attrs, slots, expose }) { const hookRefs = new Map(); - const notices = computed(() => props.notices); + const notices = shallowRef([]); + const setNotices = (_notices: NotificationState) => { + notices.value = _notices; + + const nextPlacements = {} as any; + // init placements with animation + Object.keys(placements.value).forEach(placement => { + nextPlacements[placement] = []; + }); + _notices.forEach(config => { + const { placement = 'topRight' } = config.notice; + if (placement) { + nextPlacements[placement] = nextPlacements[placement] || []; + nextPlacements[placement].push(config); + } + }); + placements.value = nextPlacements; + }; const transitionProps = computed(() => { let name = props.transitionName; if (!name && props.animation) { @@ -116,27 +134,12 @@ const Notification = defineComponent({ } return getTransitionGroupProps(name); }); - const remove = (key: Key) => props.remove(key); const placements = ref({} as Record); - watch(notices, () => { - const nextPlacements = {} as any; - // init placements with animation - Object.keys(placements.value).forEach(placement => { - nextPlacements[placement] = []; - }); - props.notices.forEach(config => { - const { placement = 'topRight' } = config.notice; - if (placement) { - nextPlacements[placement] = nextPlacements[placement] || []; - nextPlacements[placement].push(config); - } - }); - placements.value = nextPlacements; - }); - const placementList = computed(() => Object.keys(placements.value) as Placement[]); - + expose({ + setNotices, + }); return () => { const { prefixCls, closeIcon = slots.closeIcon?.({ prefixCls }) } = props; const noticeNodes = placementList.value.map(placement => { @@ -204,6 +207,7 @@ const Notification = defineComponent({ Reflect.deleteProperty(placements.value, placement); props.onAllRemoved?.(); } + return (
document.body; @@ -104,16 +104,19 @@ export default function useNotification(rootConfig: NotificationConfig = {}) { updatedNotices.push({ notice, holderCallback } as any); } notices.value = updatedNotices; + notificationsRef.value?.setNotices(updatedNotices); }; const removeNotice = (removeKey: Key) => { notices.value = notices.value.filter(({ notice: { key, userPassKey } }) => { const mergedKey = userPassKey || key; return mergedKey !== removeKey; }); + notificationsRef.value?.setNotices(notices.value); }; const destroy = () => { notices.value = []; + notificationsRef.value?.setNotices([]); }; const contextHolder = computed(() => ( @@ -121,7 +124,6 @@ export default function useNotification(rootConfig: NotificationConfig = {}) { ref={notificationsRef} prefixCls={prefixCls} maxCount={maxCount} - notices={notices.value} remove={removeNotice} getClassName={getClassName} getStyles={getStyles} @@ -129,7 +131,7 @@ export default function useNotification(rootConfig: NotificationConfig = {}) { hashId={rootConfig.hashId} onAllRemoved={onAllRemoved} getContainer={getContainer} - > + /> )); const taskQueue = shallowRef([] as Task[]); From 65d81c74e89626bf64947d6bf17be719c5049478 Mon Sep 17 00:00:00 2001 From: aibayanyu20 Date: Sat, 13 Jan 2024 10:21:03 +0800 Subject: [PATCH 3/3] ci: test --- .../__tests__/__snapshots__/demo.test.js.snap | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/notification/__tests__/__snapshots__/demo.test.js.snap b/components/notification/__tests__/__snapshots__/demo.test.js.snap index 4fdfaf200d..c50afc4ac9 100644 --- a/components/notification/__tests__/__snapshots__/demo.test.js.snap +++ b/components/notification/__tests__/__snapshots__/demo.test.js.snap @@ -27,11 +27,11 @@ exports[`renders ./components/notification/demo/duration.vue correctly 1`] = ` exports[`renders ./components/notification/demo/hook.vue correctly 1`] = `
@@ -40,11 +40,11 @@ exports[`renders ./components/notification/demo/hook.vue correctly 1`] = `
@@ -53,10 +53,10 @@ exports[`renders ./components/notification/demo/hook.vue correctly 1`] = ` `; exports[`renders ./components/notification/demo/placement.vue correctly 1`] = ` -
+
+
`;