Repository navigation
Quick Edit: add Template field - #66591
Conversation
…Press/gutenberg into add/template-form
|
Size Change: +1.07 kB (+0.06%) Total Size: 1.83 MB
ℹ️ View Unchanged
|
…Press/gutenberg into add/template-form
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Thanks for the review! |
| [ postId, postType ] | ||
| ); | ||
|
|
||
| const { availableTemplates, templates } = useSelect( |
There was a problem hiding this comment.
Why not merge both useSelect calls?
| return { | ||
| ...field, | ||
| Edit: ( data ) => ( | ||
| <ExperimentalBlockEditorProvider settings={ settings }> |
There was a problem hiding this comment.
Why is this here and not directly in the template field edit?
There was a problem hiding this comment.
Not asking to change it, just curious why
There was a problem hiding this comment.
I need to pass settings to this provider and usePatternSettings depends on the edit site store:
There was a problem hiding this comment.
Ok, here are my thoughts on this. Not necessarily something to be done here though
We need to check what settings exactly are needed for these previews. It seems mostly about the list of available patterns (maybe there's other stuff but I'm not sure). IMO, these could be provided directly from core-data package selectors... without the "settings" object. This is a cleanup that needs to be done at some point. I mention some of this here https://make.wordpress.org/core/2024/09/12/gutenberg-development-practices-and-common-pitfalls/ (It's also kind of a similar change to what we did for defaultTemplates and template parts)
I'm ok shipping this as is now but I feel like if someone uses the "template" field, it should just work without any hidden requirement.
There was a problem hiding this comment.
Thanks! I agree with you! I'm happy to:
- open an issue.
- add the issue link on this comment.
- dedicate some time in the upcoming weeks to fix this.
Co-authored-by: louwie17 <louwie17@git.wordpress.org> Co-authored-by: gigitux <gigitux@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
|
|
||
| ### templateField | ||
|
|
||
| Undocumented declaration. |
There was a problem hiding this comment.
We should aim to document every export. It's quite discouraging to look at docs that say "Undocumented declaration".
| @@ -0,0 +1,210 @@ | |||
| /** | |||
There was a problem hiding this comment.
For file names: we could simplify to edit or view if they are within a field folder.
| id: 'template', | ||
| type: 'text', | ||
| label: __( 'Template' ), | ||
| getValue: ( { item } ) => item.template, |
There was a problem hiding this comment.
We don't need to provide a getValue function here given id is template.
Co-authored-by: louwie17 <louwie17@git.wordpress.org> Co-authored-by: gigitux <gigitux@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
|
I noticed that changes from this PR were triggering |
What?
This PR is based on top of #66531
This PR is part of #64519.
Why?
This PR adds the
Templatefield.Testing Instructions
Use default template.Testing Instructions for Keyboard
Screenshots or screencast
Screen.Capture.on.2024-10-30.at.20-10-04.mp4
Drawbacks
@wordpress/block-editordependencyTo implement the modal previewing all the templates is necessary use the
__experimentalBlockPatternsListfrom the@wordpress/block-editorpackage. I think that it is acceptable.Uncaught TypeError: Cannot destructure property 'avatarURL' of '(0 , _wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(...)' as it is undefinederrorIn some cases, the templates in the modal aren't rendered correctly due to this JavaScript error:
Screen.Capture.on.2024-10-30.at.20-15-04.mov
gutenberg/packages/block-library/src/avatar/hooks.js
Lines 19 to 26 in 61f9655
This happens when the setting object isn't initialized. To fix this issue, I pushed 5a623fb. Still, I'm not sure that this is the best solution 🤔.
It is a similar issue that I tried to tackle with #66459.
cc @oandregal @youknowriad and @louwie17