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

Template field: Remove dependency with the "settings" object #67527

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

snehapatil2001
Copy link
Contributor

@snehapatil2001 snehapatil2001 commented Dec 3, 2024

What?

Resolves #67521.

Improve the Template field in the post-edit screen by removing its dependency on block editor settings and fetching template data directly from core-data.

Why?

  • The current implementation of the Template field requires wrapping with ExperimentalBlockEditorProvider and depends on block editor settings, which creates unnecessary complexity and hidden dependencies.
  • This change addresses the issue described in Gutenberg Issue #67521, where the Template field should work independently without requiring specific provider wrapping.

How?

  • Created a custom useTemplates hook to fetch template records directly from core-data
  • Removed dependency on ExperimentalBlockEditorProvider
  • Modified the Template field's Edit component to receive templates as a prop
  • Simplified the template data fetching process
  • Ensured the Template field can be used without additional context or settings

Testing Instructions

  1. Open the post/page editor
  2. Navigate to the post settings sidebar
  3. Verify the Template dropdown appears and is populated
  4. Select different templates and ensure they can be applied
  5. Test with both single and multiple post editing scenarios

Copy link

github-actions bot commented Dec 3, 2024

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: snehapatil2001 <[email protected]>
Co-authored-by: gigitux <[email protected]>

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

@gigitux
Copy link
Contributor

gigitux commented Dec 4, 2024

Thank you for working on this issue!

The template field should function independently of any data passed through PostEditForm. All data fetching should be handled within the template-edit file.

I followed the testing instructions and I got some errors:

Screen.Capture.on.2024-12-04.at.17-08-25.mov

Upon further investigation, it appears that the main issue is that multiple core blocks, such as AvatarBlock, depend on the settings object. Without ExperimentalBlockEditorProvider in this context, the settings object is unavailable.

I think that fixing #67521 removing any dependency with the settings object could not be a straightforward task given that it would require the refactor of multiple blocks.

@youknowriad could have better context on this.

@Mamaduka Mamaduka added [Type] Enhancement A suggestion for improvement. [Package] Fields /packages/fields labels Jan 13, 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] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template field: Remove dependency with the "settings" object
3 participants