Skip to content

Conversation

@lezama
Copy link
Contributor

@lezama lezama commented Dec 2, 2025

Related #70862

Summary

Adds support for a route.inspector() function in route_module that allows routes to conditionally show/hide the inspector panel based on route params or search parameters.

Usage example in route.tsx:

export const route = {
  inspector: ({ search }) => {
    // Only show inspector when items are selected
    return search.selectedIds?.length > 0;
  },
};

When the inspector function is not defined, it defaults to true (always show).
When it returns false, the inspector div is not rendered even if an inspector component is exported from the content module.

Also adds a RouteConfig interface to types.ts that documents all available route lifecycle functions (beforeLoad, loader, canvas, inspector).

Test plan

  • Routes without an inspector function should continue to show the inspector (default true)
  • Routes with inspector: () => false should hide the inspector panel
  • Routes with inspector: ({ search }) => search.selectedIds?.length > 0 should conditionally show inspector based on search params

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: lezama <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great addition and something we're going to need for quick edit in the site editor. Thanks.

@youknowriad youknowriad enabled auto-merge (squash) December 4, 2025 16:46
@youknowriad youknowriad merged commit 4e381c0 into WordPress:trunk Dec 4, 2025
33 checks passed
@github-actions github-actions bot added this to the Gutenberg 22.3 milestone Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants