Skip to content

Commit

Permalink
Fix re-renders caused by getEntityRecordsPermissions after WordPres…
Browse files Browse the repository at this point in the history
…s#67667 (WordPress#67770)

* Update getEntityRecordsPermissions signature to allow string ids
* Fix regression caused in WordPress#67667

Co-authored-by: manzoorwanijk <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored and yogeshbhutkar committed Dec 18, 2024
1 parent 3c5ae56 commit 8d860ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export const getBlockPatternsForPostType = createRegistrySelector(
*/
export const getEntityRecordsPermissions = createRegistrySelector( ( select ) =>
createSelector(
( state: State, kind: string, name: string, ids: string[] ) => {
(
state: State,
kind: string,
name: string,
ids: string | string[]
) => {
const normalizedIds = Array.isArray( ids ) ? ids : [ ids ];
return normalizedIds.map( ( id ) => ( {
delete: select( STORE_NAME ).canUser( 'delete', {
Expand Down Expand Up @@ -92,7 +97,7 @@ export function getEntityRecordPermissions(
name: string,
id: string
) {
return getEntityRecordsPermissions( state, kind, name, [ id ] )[ 0 ];
return getEntityRecordsPermissions( state, kind, name, id )[ 0 ];
}

/**
Expand Down

0 comments on commit 8d860ab

Please sign in to comment.