Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fields: Avoid 'useSelect' warnings in the template component #69344

Merged
merged 1 commit into from
Feb 27, 2025

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
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 <mamaduka@git.wordpress.org>

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
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.

1 participant