Skip to content

Core Data: Add getTitle for user entity #70941

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

Merged
merged 2 commits into from
Jul 29, 2025

Conversation

heavyweight
Copy link
Contributor

What?

Closes
The title for edited users was not resolving correctly.
This lead to changes for user entities showing as untitled in the review changes modal.
This PR adds a mechanism for generating the title for users based on their username.

Why?

  • To show better changes to users in the review changes modal

How?

Testing Instructions

wp.data.dispatch(wp.coreData.store).editEntityRecord( 'root', 'user', 1, {first_name: 'test'} )
  • In case there is an error trigger it one more time
  • This will edit the user record for the admin user with id: 1
  • You should see Review 1 change... showing at the bottom of the sidebar
  • Click on that
  • You should see the admin username displayed instead of 'Untitled'

Testing Instructions for Keyboard

Screenshots or screencast

Before After
Screenshot 2025-07-28 at 15 16 08 Screenshot 2025-07-28 at 15 12 10

@heavyweight heavyweight requested a review from nerrad as a code owner July 28, 2025 13:20
Copy link

github-actions bot commented Jul 28, 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: heavyweight <kpapazov@git.wordpress.org>
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.

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 28, 2025
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @heavyweight! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@Mamaduka Mamaduka changed the title Add getTitle for user entity Core Data: Add getTitle for user entity Jul 28, 2025
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Saving Related to saving functionality [Package] Core data /packages/core-data labels Jul 28, 2025
@@ -138,6 +138,7 @@ export const rootEntitiesConfig = [
name: 'user',
kind: 'root',
baseURL: '/wp/v2/users',
getTitle: ( record ) => record?.username || record?.slug,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
getTitle: ( record ) => record?.username || record?.slug,
getTitle: ( record ) => record?.name || record?.slug,

This matches the user data displayed in the editor by different components.

@heavyweight heavyweight requested a review from Mamaduka July 28, 2025 20:43
Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thanks for contributing, @heavyweight!

The fix works as expected ✅

Screenshot

CleanShot 2025-07-29 at 07 17 55

@Mamaduka Mamaduka merged commit 7654d4d into WordPress:trunk Jul 29, 2025
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.4 milestone Jul 29, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Jul 31, 2025
Co-authored-by: heavyweight <kpapazov@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Saving Related to saving functionality First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Core data /packages/core-data [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants