Skip to content

Conversation

@Mamaduka
Copy link
Member

What?

Discovered while working on #69341.

PR updates the TemplateEdit component to prevent useSelect warnings.

Why?

Iterating over data inside the useSelect hook callback isn't recommended and can affect performance.

Testing Instructions

  1. Enable the "Data Views: add Quick Edit" experiment.
  2. Open Site Editor > Pages and switch to the Table layout.
  3. Click the "Details" icon in the top left corner.
  4. Select a page.
  5. Confirm that warming about non-equal keys availableTemplates is no longer logged.

Testing Instructions for Keyboard

Same.

Screenshots or screencast

CleanShot 2025-02-27 at 10 17 42

CleanShot 2025-02-27 at 10 58 23

@Mamaduka Mamaduka added [Type] Code Quality Issues or PRs that relate to code quality [Package] Fields /packages/fields labels Feb 27, 2025
@Mamaduka Mamaduka self-assigned this Feb 27, 2025
@Mamaduka Mamaduka requested a review from gigitux February 27, 2025 07:02
@github-actions
Copy link

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: Mamaduka <[email protected]>

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

Comment on lines +97 to +99
const foundTemplate = templates.find(
( template ) => template.slug === value
);
Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved the lookup outside the mapSelect.

@Mamaduka Mamaduka merged commit a02bf96 into trunk Feb 27, 2025
66 checks passed
@Mamaduka Mamaduka deleted the fix/fields-template-edit-warning branch February 27, 2025 10:30
@github-actions github-actions bot added this to the Gutenberg 20.4 milestone Feb 27, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Fields /packages/fields [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants