From ef889db68afbd69795ee35160a6a35cb09eef356 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 05:05:57 +0000 Subject: [PATCH 1/2] fix(kanban): a list view board laned by a lookup loads the rest of a lane's cards with "Load more" A lane of the board a list view hands one page to drew the page's cards under the grouped read's whole count, with no way to load the rest. Each lane that draws fewer cards than the read counts now reads its next records under the view's query, from right after its cards on the page. Claude-Session: https://claude.ai/code/session_01L9qibwxBy3QieJMqJbJtTk Co-authored-by: Claude --- .../37517-kanban-host-lane-load-more.md | 10 + .../listKanbanEveryRecord-12619.test.tsx | 185 +++++++++++++++++- ui/packages/plugin-kanban/src/KanbanImpl.tsx | 6 +- .../plugin-kanban/src/KanbanLanePaging.ts | 9 + .../plugin-kanban/src/ObjectKanban.tsx | 162 ++++++++++++++- 5 files changed, 362 insertions(+), 10 deletions(-) create mode 100644 .changeset/37517-kanban-host-lane-load-more.md diff --git a/.changeset/37517-kanban-host-lane-load-more.md b/.changeset/37517-kanban-host-lane-load-more.md new file mode 100644 index 00000000000..3fffeeb56e3 --- /dev/null +++ b/.changeset/37517-kanban-host-lane-load-more.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-kanban': patch +--- + +fix(kanban): a list view board laned by a lookup loads the rest of a lane's cards with "Load more" + +Clause-②: no +Metadata-protocol: none + +A list view hands its kanban one page of the view's query. On a board laned by a lookup field, the grouped lane read counts every lane, so a lane could read 30 while drawing the 13 cards of it on the page, and a lane whose records all sat past the page (the trailing "Uncategorized" lane included) read 10 with no card and no way to see them. Each lane that draws fewer cards than the read counts now has "Load more" at its foot. It reads the lane's next records under the view's filter, sort and search, starting right after the lane's cards on the page, and adds them to the lane. The list's page and the cards a lane loaded are read again together when the list refetches. A source with no grouped door, or a read that is refused or cut, offers no "Load more", as before. Boards laned by a text field or by declared options are unchanged. Nothing to migrate. diff --git a/ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx b/ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx index bcd585a5e51..94d1c3806e6 100644 --- a/ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx +++ b/ui/packages/app-shell/src/__tests__/listKanbanEveryRecord-12619.test.tsx @@ -35,7 +35,7 @@ */ import React from 'react'; import { describe, it, expect, vi, afterEach } from 'vitest'; -import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react'; +import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; import '@testing-library/jest-dom'; import { ValueDataSource } from '@object-ui/core'; import { ActionProvider, SchemaRendererProvider } from '@object-ui/react'; @@ -672,6 +672,189 @@ describe('a lookup-laned board under a list view counts and totals each whole la expect(screen.queryByRole('group', { name: 'Uncategorized' })).toBeNull(); }); + /** + * objectstack#37517 — a lane that draws fewer cards than the lane read counts + * loads the rest in place: "Load more" at its foot reads the lane's next + * records under the view's query (its filter AND the lane value, its order, + * its search), from right after the lane's cards on the page. + */ + const loadMore = (title: string) => within(lane(title)).queryByRole('button', { name: 'Load more' }); + /** The lane reads "Load more" sent: every `crm_deal` read that names a `$skip`. */ + const laneReads = (ds: any) => + ds.find.mock.calls.filter((call: any[]) => call[0] === DEAL && call[1] && '$skip' in call[1]).map((call: any[]) => call[1]); + const hostPageRead = (ds: any) => + ds.find.mock.calls.find((call: any[]) => call[0] === DEAL && call[1] && !('$skip' in call[1]))![1]; + const cardNames = (title: string) => within(lane(title)).queryAllByRole('listitem').map((card) => card.textContent); + + it('a lane past the page loads its 10 cards in place, from its first record, and stops offering more', async () => { + const ds = dealSource(); + mountBoard(ds, BOARD_VIEW); + + await onePageDrawn(); + await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull()); + // The lane still says what it has not loaded while it offers to load it. + expect(within(lane('Cyan Corp')).getByText('Cards not loaded: 10')).toBeInTheDocument(); + expect(laneReads(ds)).toHaveLength(0); + + fireEvent.click(loadMore('Cyan Corp')!); + + // Drawn from its cards now, the lane is titled as the page's lanes are: by + // the record its cards reference, which this source does not expand, so by + // its key (`acc-c`), and in the same place. + await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10)); + expect(laneNames().slice(-3)).toEqual(['acc-a', 'acc-b', 'acc-c']); + expect(loadMore('acc-c')).toBeNull(); + expect(laneBadge('acc-c')).toBe('10'); + expect(within(lane('acc-c')).queryByText('Cards not loaded: 10')).toBeNull(); + // The other lanes keep their page's cards. + expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(13); + expect(cards()).toHaveLength(35); + const reads = laneReads(ds); + expect(reads).toHaveLength(1); + expect(reads[0]).toMatchObject({ $skip: 0, $top: 50, $count: true }); + expect(JSON.stringify(reads[0].$filter)).toContain('"account","=","acc-c"'); + expect(reads[0].$orderby).toEqual(hostPageRead(ds).$orderby); + }); + + it('a lane on the page with 13 of its 30 cards loads the other 17 from its 14th record, none twice', async () => { + const ds = dealSource(); + mountBoard(ds, BOARD_VIEW); + + await onePageDrawn(); + await waitFor(() => expect(loadMore('acc-a')).not.toBeNull()); + expect(loadMore('acc-b')).not.toBeNull(); + + fireEvent.click(loadMore('acc-a')!); + + await waitFor(() => expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(30)); + expect(new Set(cardNames('acc-a')).size).toBe(30); + expect(loadMore('acc-a')).toBeNull(); + expect(laneBadge('acc-a')).toBe('30'); + // acc-b is untouched: its page's 12 and its "Load more". + expect(within(lane('acc-b')).getAllByRole('listitem')).toHaveLength(12); + expect(loadMore('acc-b')).not.toBeNull(); + const reads = laneReads(ds); + expect(reads).toHaveLength(1); + expect(reads[0]).toMatchObject({ $skip: 13, $top: 50 }); + expect(JSON.stringify(reads[0].$filter)).toContain('"account","=","acc-a"'); + }); + + it('a page that repeats a card the lane already holds draws it once', async () => { + // A source whose lane read starts two records early, as a sort with ties + // may answer: deals 22 and 24 come back a second time. + const ds = dealSource(); + const find = ds.find.getMockImplementation(); + ds.find.mockImplementation((object: string, params: any) => + find(object, params && '$skip' in params ? { ...params, $skip: Math.max(0, params.$skip - 2) } : params)); + mountBoard(ds, BOARD_VIEW); + + await onePageDrawn(); + await waitFor(() => expect(loadMore('acc-a')).not.toBeNull()); + fireEvent.click(loadMore('acc-a')!); + + await waitFor(() => expect(laneReads(ds)).toHaveLength(1)); + await waitFor(() => expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(30)); + expect(new Set(cardNames('acc-a')).size).toBe(30); + expect(laneBadge('acc-a')).toBe('30'); + }); + + it('reads under the view\'s filter, the one its own window was fetched with', async () => { + const ds = dealSource(); + mountBoard(ds, { ...BOARD_VIEW, filter: [{ field: 'amount', operator: 'greater_than', value: 9 }] }); + + await waitFor(() => expect(cards()).toHaveLength(25)); + await waitFor(() => expect(loadMore('acc-a')).not.toBeNull()); + fireEvent.click(loadMore('acc-a')!); + + // 10, 12, … 58: 25 records, 13 of them on the page. + await waitFor(() => expect(within(lane('acc-a')).getAllByRole('listitem')).toHaveLength(25)); + expect(loadMore('acc-a')).toBeNull(); + const read = laneReads(ds)[0]; + expect(read.$skip).toBe(13); + expect(JSON.stringify(read.$filter)).toContain('amount'); + expect(JSON.stringify(read.$filter)).toContain('"account","=","acc-a"'); + }); + + it('the "Uncategorized" lane past the page loads its records with no account', async () => { + const ds = dealSource(true, NO_ACCOUNT_PAST_PAGE); + mountBoard(ds, BOARD_VIEW); + + await onePageDrawn(); + await waitFor(() => expect(loadMore('Uncategorized')).not.toBeNull()); + expect(within(lane('Uncategorized')).getByText('Cards not loaded: 10')).toBeInTheDocument(); + fireEvent.click(loadMore('Uncategorized')!); + + await waitFor(() => expect(within(lane('Uncategorized')).getAllByRole('listitem')).toHaveLength(10)); + expect(loadMore('Uncategorized')).toBeNull(); + expect(laneBadge('Uncategorized')).toBe('10'); + const read = laneReads(ds)[0]; + expect(read.$skip).toBe(0); + expect(JSON.stringify(read.$filter)).toContain('"account","is_null"'); + }); + + it('the cards a lane loaded go when the list reads its page again (Refresh), and the lane offers them again', async () => { + const ds = dealSource(); + mountBoard(ds, { ...BOARD_VIEW, compactToolbar: false }); + + await onePageDrawn(); + await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull()); + fireEvent.click(loadMore('Cyan Corp')!); + await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10)); + + fireEvent.click(screen.getByTestId('refresh-button')); + + await waitFor(() => expect(within(lane('Cyan Corp')).queryAllByRole('listitem')).toHaveLength(0)); + await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull()); + expect(within(lane('Cyan Corp')).getByText('Cards not loaded: 10')).toBeInTheDocument(); + expect(cards()).toHaveLength(25); + }); + + it('the cards a lane loaded go when the toolbar search changes, and the next read carries the search', async () => { + const ds = dealSource(); + mountBoard(ds, { ...BOARD_VIEW, compactToolbar: false }); + + await onePageDrawn(); + await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull()); + fireEvent.click(loadMore('Cyan Corp')!); + await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10)); + + // Every deal is named "Deal …", so the search keeps every record. + fireEvent.click(screen.getByTestId('search-icon-button')); + fireEvent.change(screen.getByPlaceholderText(/search/i), { target: { value: 'Deal' } }); + + await waitFor(() => expect(within(lane('Cyan Corp')).queryAllByRole('listitem')).toHaveLength(0)); + await waitFor(() => expect(loadMore('Cyan Corp')).not.toBeNull()); + fireEvent.click(loadMore('Cyan Corp')!); + await waitFor(() => expect(within(lane('acc-c')).getAllByRole('listitem')).toHaveLength(10)); + const reads = laneReads(ds); + expect(reads).toHaveLength(2); + expect(reads[0].$search).toBeUndefined(); + expect(reads[1]).toMatchObject({ $search: 'Deal', $skip: 0 }); + }); + + it.each([ + ['has no grouped door', false], + ['refuses the read', 'refuse'], + ['cuts the read (hasMore)', 'cut'], + ] as const)('CONTROL: when the source %s, no lane offers "Load more"', async (_, door) => { + const ds = dealSource(door, NO_ACCOUNT_PAST_PAGE); + mountBoard(ds, BOARD_VIEW); + + await onePageDrawn(); + if (door !== false) await waitFor(() => expect(ds.queryGroupHeaders).toHaveBeenCalledTimes(1)); + await waitFor(() => expect(laneBadge('acc-a')).toBe('13+')); + expect(screen.queryAllByRole('button', { name: 'Load more' })).toHaveLength(0); + expect(laneReads(ds)).toHaveLength(0); + }); + + it('CONTROL: a board laned by a text field offers no "Load more"', async () => { + mountBoard(dealSource(), { ...BOARD_VIEW, kanban: { ...BOARD_VIEW.kanban, groupByField: 'tier' } }); + + await waitFor(() => expect(cards()).toHaveLength(25)); + await waitFor(() => expect(laneBadge('gold')).toBe('30')); + expect(screen.queryAllByRole('button', { name: 'Load more' })).toHaveLength(0); + }); + it('a board laned by a text field counts each whole lane but draws no lane past the page', async () => { const ds = dealSource(); mountBoard(ds, { ...BOARD_VIEW, kanban: { ...BOARD_VIEW.kanban, groupByField: 'tier' } }); diff --git a/ui/packages/plugin-kanban/src/KanbanImpl.tsx b/ui/packages/plugin-kanban/src/KanbanImpl.tsx index 6706359d767..19e29a2b1b3 100644 --- a/ui/packages/plugin-kanban/src/KanbanImpl.tsx +++ b/ui/packages/plugin-kanban/src/KanbanImpl.tsx @@ -1222,7 +1222,11 @@ function KanbanColumnView({ // objectstack#37327 — a lane of a board handed one page of its query writes // the grouped read's whole count, and its page count marked `+` while the // read has not answered or cannot (see `KanbanBoardProps.laneCounts`). - const hostCount = pagedCount ? null : wholeLaneCount(laneCounts, String(column.id), safeCards.length) + // Read beside a lane page too (objectstack#37517): that board's lanes carry + // a page for their "Load more", and a lane none of whose records is on the + // board still says so. `laneCounts` is set only on a board handed one page, + // which never pages its lanes itself, so a self-paged lane reads `null` here. + const hostCount = wholeLaneCount(laneCounts, String(column.id), safeCards.length) const laneCountOf = pagedCount ?? hostCount // A lane that holds records none of which is on the page draws that, never // "No cards" under a count above zero. diff --git a/ui/packages/plugin-kanban/src/KanbanLanePaging.ts b/ui/packages/plugin-kanban/src/KanbanLanePaging.ts index 40d9a335738..6c0cc78e123 100644 --- a/ui/packages/plugin-kanban/src/KanbanLanePaging.ts +++ b/ui/packages/plugin-kanban/src/KanbanLanePaging.ts @@ -107,6 +107,15 @@ export function uncolumnedQueryFilter(base: unknown, laneField: string, laneIds: return mergeFilterNodes(base, ['or', [laneField, 'nin', [...laneIds]], [laneField, 'is_null']]); } +/** + * The view's filter AND "no lane value": the records of the trailing + * "Uncategorized" lane on a board whose lanes come from the data + * (objectstack#37517), where every value the records hold is a lane of its own. + */ +export function emptyLaneQueryFilter(base: unknown, laneField: string): unknown { + return mergeFilterNodes(base, [laneField, 'is_null']); +} + /** * One lane query's answer as a page: its records, and the lane's count when the * source answered one. `loadedBefore` is what the lane already held, for a diff --git a/ui/packages/plugin-kanban/src/ObjectKanban.tsx b/ui/packages/plugin-kanban/src/ObjectKanban.tsx index 911ca24dfa3..c02546b01c5 100644 --- a/ui/packages/plugin-kanban/src/ObjectKanban.tsx +++ b/ui/packages/plugin-kanban/src/ObjectKanban.tsx @@ -77,6 +77,7 @@ import { KanbanLaneMenuContext, type KanbanLaneMenu, type KanbanLaneMenuRequest import { KANBAN_LANE_PAGE_SIZE, KanbanLanePagingContext, + emptyLaneQueryFilter, laneQueryFilter, readLanePage, uncolumnedQueryFilter, @@ -86,7 +87,7 @@ import { } from './KanbanLanePaging'; import { resolveCardOwner, type KanbanCardOwner } from './KanbanCardOwner'; import { lanesFromOptions, type LaneLifecycleKind } from './kanbanLaneLifecycle'; -import { lanesFromRecords, laneValueOf } from './kanbanReferenceLanes'; +import { laneKeyOf, lanesFromRecords, laneValueOf } from './kanbanReferenceLanes'; import { compileLaneReadQuery, isLaneAggregate, @@ -1149,13 +1150,44 @@ export const ObjectKanban: React.FC = ({ }); }, [dataSource]); - const lanePagingChannel = useMemo( - () => (lanePages ? { pages: lanePages, loadMore: loadMoreLane } : null), - [lanePages, loadMoreLane], + /** + * objectstack#37517 — the cards a lane of a board its host hands ONE page to + * loaded past that page ("Load more" at the lane's foot, `loadMoreHostLane` + * below), held under the question the page answers. The host's page is the + * first page of the view's query, in the view's order (the list pages only + * its grid), so the cards of one lane on it are that lane's first records in + * the same order: the lane's next records start right after them. Appended + * to the host's rows, never replacing them; a new page from the host (a + * refetch, a refresh, another filter, search or sort) starts every lane over. + */ + type HostLaneRows = { + question: string; + rows: any[]; + /** The lanes with a read on its way. */ + loading: Record; + /** The lanes whose last read answered no more records. */ + done: Record; + }; + const [hostLaneRows, setHostLaneRows] = useState(null); + const hostPageIdsKey = useMemo( + () => (hasExternalData ? JSON.stringify((externalData as any[]).map((row) => String(row?.id ?? row?._id))) : ''), + [hasExternalData, externalData], ); + const hostPageQuestion = hasExternalData + ? JSON.stringify([schemaKey, schema.groupBy ?? null, queryFilterKey, sortKey, hostSearchKey, hostReloadKey, refreshKey, hostPageIdsKey]) + : ''; + const hostPageQuestionRef = React.useRef(hostPageQuestion); + hostPageQuestionRef.current = hostPageQuestion; + const hostLaneRowsHeld = hostLaneRows && hostLaneRows.question === hostPageQuestion && hostPageQuestion !== '' ? hostLaneRows : null; + const hostBoardData = useMemo(() => { + if (!hasExternalData) return undefined; + if (!hostLaneRowsHeld || hostLaneRowsHeld.rows.length === 0) return externalData; + const seen = new Set((externalData as any[]).map((row) => String(row?.id ?? row?._id))); + return [...(externalData as any[]), ...hostLaneRowsHeld.rows.filter((row) => !seen.has(String(row?.id ?? row?._id)))]; + }, [hasExternalData, externalData, hostLaneRowsHeld]); // Determine which data to use: external -> bound -> inline -> fetched - const rawData = (hasExternalData ? externalData : undefined) || boundData || schema.data || fetchedData; + const rawData = hostBoardData || boundData || schema.data || fetchedData; /** * Are the lane counts about to be drawn counts of a WINDOW (`5591f03bd`)? @@ -1883,9 +1915,123 @@ export const ObjectKanban: React.FC = ({ * lanes past the page take. A partial or refused read answers no counts * (`hostLaneCounts` null), and no lane is drawn from it. */ - const keepUncolumned = - hostLaneRead && flatLanes && lanesFromData && !!laneTargetObject - && (hostLaneCounts?.[KANBAN_UNCOLUMNED_ID] ?? 0) > 0; + const pastPageLanes = hostLaneRead && flatLanes && lanesFromData && !!laneTargetObject; + const keepUncolumned = pastPageLanes && (hostLaneCounts?.[KANBAN_UNCOLUMNED_ID] ?? 0) > 0; + /** + * objectstack#37517 — "Load more" on a lane of the board handed one page: + * every lane whose cards on the board are fewer than the lane read counts, + * the lanes past the page and the trailing "Uncategorized" lane included, + * under the gate those lanes are drawn under. A partial or refused read + * answers no counts, so no lane offers more than the read answered. + * + * `loaded` is the lane's cards on the board: the host page's cards in it + * (the lane's first records, see `hostLaneRows`) and the ones read since, + * so it is the `$skip` of the lane's next read. + */ + const hostLanePagingOn = pastPageLanes && !!hostLaneCounts; + const hostLanePages = useMemo((): Record | null => { + if (!hostLanePagingOn || !hostLaneCounts || !schema.groupBy || !Array.isArray(rawData)) return null; + const groupBy = schema.groupBy; + const onBoard: Record = Object.create(null); + for (const row of rawData as any[]) { + const key = laneKeyOf(row?.[groupBy]); + const laneId = key === '' ? KANBAN_UNCOLUMNED_ID : key; + onBoard[laneId] = (onBoard[laneId] ?? 0) + 1; + } + const pages: Record = {}; + for (const [laneId, total] of Object.entries(hostLaneCounts)) { + const loaded = onBoard[laneId] ?? 0; + const loading = hostLaneRowsHeld?.loading[laneId] === true; + const hasMore = loaded < total && hostLaneRowsHeld?.done[laneId] !== true; + if (hasMore || loading) pages[laneId] = { total, loaded, hasMore, loading }; + } + return pages; + }, [hostLanePagingOn, hostLaneCounts, schema.groupBy, rawData, hostLaneRowsHeld]); + // Read by `loadMoreHostLane`, which must not change on every render. + const hostLaneReadRef = React.useRef<{ + question: string; + pages: Record | null; + objectName: string; + groupBy: string; + filter: unknown; + params: Record; + } | null>(null); + { + // The lane's next records, under the query the host's page answers: its + // filter, sort, search and expansion (FLS-gated as the board's own query + // is, objectui#7429), with the lane's count beside them. + const expandable = buildExpandFields(objectDef?.fields); + const expand = !perms?.isLoaded || !schema.objectName + ? expandable + : expandable.filter((f) => perms.checkField(schema.objectName as string, f, 'read')); + hostLaneReadRef.current = hostLanePages && schema.objectName && schema.groupBy + ? { + question: hostPageQuestion, + pages: hostLanePages, + objectName: schema.objectName, + groupBy: schema.groupBy, + filter: queryFilter, + params: { + $orderby: convertSortToQueryParams(schema.sort), + ...(expand.length > 0 ? { $expand: expand } : {}), + ...(JSON.parse(hostSearchKey) as Record), + $count: true, + }, + } + : null; + } + const loadMoreHostLane = React.useCallback((laneId: string) => { + const held = hostLaneReadRef.current; + const page = held?.pages?.[laneId]; + if (!held || !page || !page.hasMore || page.loading) return; + if (!dataSource || typeof dataSource.find !== 'function') return; + const { question } = held; + const mark = (update: (prev: HostLaneRows) => HostLaneRows) => + setHostLaneRows((prev) => { + const base = prev && prev.question === question ? prev : { question, rows: [], loading: {}, done: {} }; + return update(base); + }); + const settle = (prev: HostLaneRows): Record => { + const { [laneId]: _settled, ...loading } = prev.loading; + return loading; + }; + mark((prev) => ({ ...prev, loading: { ...prev.loading, [laneId]: true } })); + const filter = laneId === KANBAN_UNCOLUMNED_ID + ? emptyLaneQueryFilter(held.filter, held.groupBy) + : laneQueryFilter(held.filter, held.groupBy, laneId); + dataSource + .find(held.objectName, { ...held.params, $filter: filter, $skip: page.loaded, $top: KANBAN_LANE_PAGE_SIZE } as any) + .then((result) => { + // A page answering an older question is dropped with it. + if (hostPageQuestionRef.current !== question) return; + const next = readLanePage(result, page.loaded, KANBAN_LANE_PAGE_SIZE); + mark((prev) => { + const seen = new Set(prev.rows.map((row) => String(row?.id ?? row?._id))); + return { + ...prev, + rows: [...prev.rows, ...next.rows.filter((row) => !seen.has(String(row?.id ?? row?._id)))], + loading: settle(prev), + // A read that answers no more stops the lane offering more, so a + // count the records moved away from cannot ask the same page forever. + done: next.page.hasMore && next.rows.length > 0 ? prev.done : { ...prev.done, [laneId]: true }, + }; + }); + }) + .catch((err) => { + if (hostPageQuestionRef.current !== question) return; + console.error('[ObjectKanban] Load more failed:', err); + // The lane keeps what it holds, and its "Load more" stays to retry. + mark((prev) => ({ ...prev, loading: settle(prev) })); + }); + }, [dataSource]); + const lanePagingChannel = useMemo( + () => (lanePages + ? { pages: lanePages, loadMore: loadMoreLane } + : hostLanePages + ? { pages: hostLanePages, loadMore: loadMoreHostLane } + : null), + [lanePages, loadMoreLane, hostLanePages, loadMoreHostLane], + ); const extraLaneIdsKey = JSON.stringify(extraLaneIds); const [extraLaneTitles, setExtraLaneTitles] = useState<{ key: string; titles: Record } | null>(null); useEffect(() => { From 1a8a0662926882b41a5c90f901a7a78de422362e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 06:02:48 +0000 Subject: [PATCH 2/2] fix(kanban): keep the record-source ladder line; draw the loaded lane rows through boardData The on-disk pin of the ladder (object-kanban-record-source-7780) reads the rawData line verbatim. rawData resolves as before; the rows a lane loaded past the host's page are appended in boardData, which the cards, the lane pages and the drag handlers read. Claude-Session: https://claude.ai/code/session_01L9qibwxBy3QieJMqJbJtTk Co-authored-by: Claude --- .../plugin-kanban/src/ObjectKanban.tsx | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/ui/packages/plugin-kanban/src/ObjectKanban.tsx b/ui/packages/plugin-kanban/src/ObjectKanban.tsx index c02546b01c5..9e83facbef9 100644 --- a/ui/packages/plugin-kanban/src/ObjectKanban.tsx +++ b/ui/packages/plugin-kanban/src/ObjectKanban.tsx @@ -1179,15 +1179,19 @@ export const ObjectKanban: React.FC = ({ const hostPageQuestionRef = React.useRef(hostPageQuestion); hostPageQuestionRef.current = hostPageQuestion; const hostLaneRowsHeld = hostLaneRows && hostLaneRows.question === hostPageQuestion && hostPageQuestion !== '' ? hostLaneRows : null; - const hostBoardData = useMemo(() => { - if (!hasExternalData) return undefined; - if (!hostLaneRowsHeld || hostLaneRowsHeld.rows.length === 0) return externalData; - const seen = new Set((externalData as any[]).map((row) => String(row?.id ?? row?._id))); - return [...(externalData as any[]), ...hostLaneRowsHeld.rows.filter((row) => !seen.has(String(row?.id ?? row?._id)))]; - }, [hasExternalData, externalData, hostLaneRowsHeld]); // Determine which data to use: external -> bound -> inline -> fetched - const rawData = hostBoardData || boundData || schema.data || fetchedData; + const rawData = (hasExternalData ? externalData : undefined) || boundData || schema.data || fetchedData; + /** + * The records the board draws: `rawData`, and on the board handed one page, + * the host's rows followed by the ones its lanes loaded past it + * (`hostLaneRows`), each record once. + */ + const boardData = useMemo(() => { + if (!hostLaneRowsHeld || hostLaneRowsHeld.rows.length === 0 || rawData !== externalData) return rawData; + const seen = new Set((rawData as any[]).map((row) => String(row?.id ?? row?._id))); + return [...(rawData as any[]), ...hostLaneRowsHeld.rows.filter((row) => !seen.has(String(row?.id ?? row?._id)))]; + }, [rawData, externalData, hostLaneRowsHeld]); /** * Are the lane counts about to be drawn counts of a WINDOW (`5591f03bd`)? @@ -1250,7 +1254,7 @@ export const ObjectKanban: React.FC = ({ // (objectui#11815). const predicateScope = usePredicateScope(); const effectiveData = useMemo(() => { - if (!Array.isArray(rawData)) return []; + if (!Array.isArray(boardData)) return []; // The author's card-title choice — `cardTitle`, else the legacy // `titleField`, and `''` on either counts as unset. Resolved by the shared @@ -1305,7 +1309,7 @@ export const ObjectKanban: React.FC = ({ // if the second rung is ever added here. const nameFieldKey: string | undefined = resolveNameField(objectDef); - return rawData.map(item => { + return boardData.map(item => { let resolvedTitle: any = undefined; // 1. The explicit title field (`resolveKanbanTitleField`). @@ -1635,7 +1639,7 @@ export const ObjectKanban: React.FC = ({ ...(cardOwner ? { cardOwner } : {}), }; }); - }, [rawData, schema, objectDef, ownerField, ownerReadable, ownerPersonObject, perms, predicateScope]); + }, [boardData, schema, objectDef, ownerField, ownerReadable, ownerPersonObject, perms, predicateScope]); // Generate columns if missing but groupBy is present const effectiveColumns = useMemo(() => { @@ -1930,10 +1934,10 @@ export const ObjectKanban: React.FC = ({ */ const hostLanePagingOn = pastPageLanes && !!hostLaneCounts; const hostLanePages = useMemo((): Record | null => { - if (!hostLanePagingOn || !hostLaneCounts || !schema.groupBy || !Array.isArray(rawData)) return null; + if (!hostLanePagingOn || !hostLaneCounts || !schema.groupBy || !Array.isArray(boardData)) return null; const groupBy = schema.groupBy; const onBoard: Record = Object.create(null); - for (const row of rawData as any[]) { + for (const row of boardData as any[]) { const key = laneKeyOf(row?.[groupBy]); const laneId = key === '' ? KANBAN_UNCOLUMNED_ID : key; onBoard[laneId] = (onBoard[laneId] ?? 0) + 1; @@ -1946,7 +1950,7 @@ export const ObjectKanban: React.FC = ({ if (hasMore || loading) pages[laneId] = { total, loaded, hasMore, loading }; } return pages; - }, [hostLanePagingOn, hostLaneCounts, schema.groupBy, rawData, hostLaneRowsHeld]); + }, [hostLanePagingOn, hostLaneCounts, schema.groupBy, boardData, hostLaneRowsHeld]); // Read by `loadMoreHostLane`, which must not change on every render. const hostLaneReadRef = React.useRef<{ question: string; @@ -2289,7 +2293,7 @@ export const ObjectKanban: React.FC = ({ // foreign key, and that is what the write sends; the record held locally // keeps the referenced record expanded, as a refetch would return it, so // the card goes on naming it (and the rollback restores what it held). - const loaded: Array> = Array.isArray(rawData) ? rawData : []; + const loaded: Array> = Array.isArray(boardData) ? boardData : []; const priorValue = loaded.find((r) => String(r?.id ?? r?._id) === String(cardId))?.[groupBy]; const movedValue = laneValueOf(loaded, groupBy, toColumnId); @@ -2385,7 +2389,7 @@ export const ObjectKanban: React.FC = ({ return { kind: 'refused', message: refusal }; } }, - [schema.groupBy, schema.objectName, dataSource, hasExternalData, tt, rawData], + [schema.groupBy, schema.objectName, dataSource, hasExternalData, tt, boardData], ); /** @@ -2494,7 +2498,7 @@ export const ObjectKanban: React.FC = ({ // The record as stored, not the card-shaped projection: `effectiveData` // overlays a derived `title`/`badges`, and the predicates must see the // record's own field values. - const record = (Array.isArray(rawData) ? rawData : []).find( + const record = (Array.isArray(boardData) ? boardData : []).find( (r) => String(r?.id ?? r?._id) === String(cardId), ); // The lane field's conditional lock over THIS record (`readonlyWhen`, the @@ -2522,7 +2526,7 @@ export const ObjectKanban: React.FC = ({ return persistCardMove(cardId, fromColumnId, toColumnId); }, - [schema.groupBy, rawData, objectDef, persistCardMove, tt, predicateScope], + [schema.groupBy, boardData, objectDef, persistCardMove, tt, predicateScope], ); // Label + localized options for each prompted field, resolved with the same