Skip to content

Navigation block: useNavigationEntities fetches all page fields #75942

@burhandodhy

Description

@burhandodhy

Description

In packages/block-library/src/navigation/use-navigation-entities.js, the hook fetches all top-level pages through the REST API without specifying _fields:

useEntityRecords( 'postType', 'page', {
		parent: 0,
		order: 'asc',
		orderby: 'id',
		per_page: -1,
		context: 'view',
	} );

This causes the API to return complete page objects – including content, excerpt, meta, guid, modified, template, _links, and many more fields the Navigation block will never use.

Additionally, this request fires every time the Navigation block mounts and re-fires after a post is saved. On sites with a large amount of content within those pages, this can cause noticeable delays and negatively impact the overall editing experience.

Proposed Fix

Add _fields to the query arguments to limit the response to only the required fields (e.g., id, title, slug, parent, menu_order).

useEntityRecords( 'postType', 'page', {
	parent: 0,
	order: 'asc',
	orderby: 'id',
	per_page: -1,
	context: 'view',
	_fields: 'id,title,slug,parent,menu_order',
} );

Step-by-step reproduction instructions

  1. Add the Navigation block.
  2. Save the post.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

Labels

Needs DecisionNeeds a decision to be actionable or relevant[Block] NavigationAffects the Navigation Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions