diff --git a/resources/js/visual-editor/vendor/__tests__/core-data-shim.test.tsx b/resources/js/visual-editor/vendor/__tests__/core-data-shim.test.tsx index dd644eb4c..670a0739d 100644 --- a/resources/js/visual-editor/vendor/__tests__/core-data-shim.test.tsx +++ b/resources/js/visual-editor/vendor/__tests__/core-data-shim.test.tsx @@ -507,7 +507,8 @@ describe('core-data-shim fetch → cache', () => { // wiped but `hasFinishedResolution` stayed true, so the next // read returned the empty wiped cache forever — until the user // refreshed the page. - const listFetcher = vi.fn(async (url: string) => { + const listFetcher = vi.fn(async (input: RequestInfo | URL, _init?: RequestInit) => { + const url = String(input); if (url.includes('per_page=-1')) { return jsonResponse({ data: [ @@ -569,7 +570,8 @@ describe('core-data-shim fetch → cache', () => { configureCoreDataShim({ apiBase: '/api', - fetcher: vi.fn(async (url: string) => { + fetcher: vi.fn(async (input: RequestInfo | URL, _init?: RequestInit) => { + const url = String(input); if (url.includes('per_page=-1')) { listFetchCount += 1; @@ -1725,9 +1727,10 @@ describe('core-data-shim hooks', () => { }, ]); - const [blocks] = renderHook(() => + const [rawBlocks] = renderHook(() => useEntityBlockEditor('postType', 'wp_template_part', { id: 1 }), - ) as readonly Array<{ + ); + const blocks = rawBlocks as ReadonlyArray<{ name: string; clientId: string; isValid: true; @@ -1774,9 +1777,10 @@ describe('core-data-shim hooks', () => { }, ]); - const [blocks] = renderHook(() => + const [rawBlocks] = renderHook(() => useEntityBlockEditor('postType', 'wp_navigation', { id: 42 }), - ) as readonly Array<{ + ); + const blocks = rawBlocks as ReadonlyArray<{ name: string; clientId: string; attributes: Record; diff --git a/resources/js/visual-editor/vendor/core-data-shim.ts b/resources/js/visual-editor/vendor/core-data-shim.ts index e6c013584..069dee19f 100644 --- a/resources/js/visual-editor/vendor/core-data-shim.ts +++ b/resources/js/visual-editor/vendor/core-data-shim.ts @@ -1765,6 +1765,10 @@ const actions = { const edited = select.getEditedEntityRecord(kind, name, id); + if (edited === null) { + return null; + } + const config = select.getEntityConfig(kind, name); const payload: EntityRecord = config ? { ...edited, [config.key]: id } @@ -1986,11 +1990,8 @@ export function useEntityProp( const ambientId = useEntityId(); const resolvedId = id !== undefined && id !== null ? id : ambientId; - const { editedValue, fullValue } = useSelect<{ - editedValue: T | undefined; - fullValue: T | undefined; - }>( - (select) => { + const { editedValue, fullValue } = useSelect( + (select: (store: S) => unknown) => { if ( kind === undefined || name === undefined ||