diff --git a/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaSettings.test.ts b/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaSettings.test.ts index 4ebb937f4..decd2f0e0 100644 --- a/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaSettings.test.ts +++ b/packages/plugins/@nocobase/plugin-gantt/src/client/__e2e__/schemaSettings.test.ts @@ -26,7 +26,7 @@ test.describe('configure params in gantt block', () => { await page.getByRole('spinbutton').fill('1'); const [request] = await Promise.all([ page.waitForRequest((request) => request.url().includes('api/general:list')), - page.getByRole('button', { name: 'OK' }).click(), + page.getByRole('button', { name: 'OK', exact: true }).click(), ]); const requestUrl = request.url(); const queryParams = new URLSearchParams(new URL(requestUrl).search); diff --git a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.tsx b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.tsx index fdcac8cdf..fdcd2a8a5 100644 --- a/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.tsx +++ b/packages/plugins/@nocobase/plugin-kanban/src/client/Kanban.tsx @@ -53,7 +53,7 @@ export const toColumns = (groupField: any, dataSource: Array = []) => { export const Kanban: any = observer( (props: any) => { const { styles } = useStyles(); - const { groupField, onCardDragEnd, ...restProps } = useProps(props); + const { groupField, onCardDragEnd, dataSource, setDataSource, ...restProps } = useProps(props); const field = useField(); const fieldSchema = useFieldSchema(); const [disableCardDrag, setDisableCardDrag] = useState(false); @@ -77,11 +77,13 @@ export const Kanban: any = observer( const handleCardRemove = (card, column) => { const updatedBoard = Board.removeCard({ columns: field.value }, column, card); field.value = updatedBoard.columns; + setDataSource(updatedBoard.columns); }; const handleCardDragEnd = (card, fromColumn, toColumn) => { onCardDragEnd?.({ columns: field.value, groupField }, fromColumn, toColumn); const updatedBoard = Board.moveCard({ columns: field.value }, fromColumn, toColumn); field.value = updatedBoard.columns; + setDataSource(updatedBoard.columns); }; return ( @@ -99,7 +101,7 @@ export const Kanban: any = observer( )} renderCard={(card, { column, dragging }) => { - const columnIndex = field.value?.indexOf(column); + const columnIndex = dataSource?.indexOf(column); const cardIndex = column?.cards?.indexOf(card); return ( schemas.card && ( @@ -136,7 +138,7 @@ export const Kanban: any = observer( }} > {{ - columns: field.value || [], + columns: dataSource || [], }} diff --git a/packages/plugins/@nocobase/plugin-kanban/src/client/KanbanBlockProvider.tsx b/packages/plugins/@nocobase/plugin-kanban/src/client/KanbanBlockProvider.tsx index 4df38cbac..0b717e5fd 100644 --- a/packages/plugins/@nocobase/plugin-kanban/src/client/KanbanBlockProvider.tsx +++ b/packages/plugins/@nocobase/plugin-kanban/src/client/KanbanBlockProvider.tsx @@ -2,7 +2,7 @@ import { ArrayField } from '@formily/core'; import { Schema, useField, useFieldSchema } from '@formily/react'; import { Spin } from 'antd'; import uniq from 'lodash/uniq'; -import React, { createContext, useContext, useEffect } from 'react'; +import React, { createContext, useContext, useEffect, useState } from 'react'; import { useACLRoleContext, useCollection, @@ -135,15 +135,17 @@ const useDisableCardDrag = () => { export const useKanbanBlockProps = () => { const field = useField(); const ctx = useKanbanBlockContext(); + const [dataSource, setDataSource] = useState([]); useEffect(() => { if (!ctx?.service?.loading) { - setTimeout(() => { - field.value = toColumns(ctx.groupField, ctx?.service?.data?.data); - }); + field.value = toColumns(ctx.groupField, ctx?.service?.data?.data); + setDataSource(toColumns(ctx.groupField, ctx?.service?.data?.data)); } // field.loading = ctx?.service?.loading; }, [ctx?.service?.loading]); return { + setDataSource, + dataSource, groupField: ctx.groupField, disableCardDrag: useDisableCardDrag(), async onCardDragEnd({ columns, groupField }, { fromColumnId, fromPosition }, { toColumnId, toPosition }) { diff --git a/packages/plugins/@nocobase/plugin-kanban/src/client/__e2e__/schemaSettings.test.ts b/packages/plugins/@nocobase/plugin-kanban/src/client/__e2e__/schemaSettings.test.ts index c072ed90e..037a57bfa 100644 --- a/packages/plugins/@nocobase/plugin-kanban/src/client/__e2e__/schemaSettings.test.ts +++ b/packages/plugins/@nocobase/plugin-kanban/src/client/__e2e__/schemaSettings.test.ts @@ -40,7 +40,7 @@ test.describe('configure setting', () => { await page.getByRole('spinbutton').fill('1'); const [request] = await Promise.all([ page.waitForRequest((request) => request.url().includes('api/general:list')), - page.getByRole('button', { name: 'OK' }).click(), + page.getByRole('button', { name: 'OK', exact: true }).click(), ]); const requestUrl = request.url(); const queryParams = new URLSearchParams(new URL(requestUrl).search);