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 #67521

Open
gigitux opened this issue Dec 3, 2024 · 0 comments
Open

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

gigitux opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
[Package] Fields /packages/fields [Type] Enhancement A suggestion for improvement.

Comments

@gigitux
Copy link
Contributor

gigitux commented Dec 3, 2024

Currently, the Template field works only if it wrapped by the ExperimentalBlockEditorProvider provider passing the settings object obtained via usePatternSettings.

/**
* The template field depends on the block editor settings.
* This is a workaround to ensure that the block editor settings are available.
*/
const fieldsWithDependency = useMemo( () => {
return fields.map( ( field ) => {
if ( field.id === 'template' ) {
return {
...field,
Edit: ( data ) => (
<ExperimentalBlockEditorProvider settings={ settings }>
<field.Edit { ...data } />
</ExperimentalBlockEditorProvider>
),
};
}
return field;
} );
}, [ fields, settings ] );

Instead, the Template field should work without any hidden requirement. For this reason, to get the necessary data, core-data package could be used instead of the settings object.

See #66591 (comment)

@gigitux gigitux added the [Package] Fields /packages/fields label Dec 3, 2024
@gigitux gigitux self-assigned this Dec 3, 2024
@gigitux gigitux added the [Type] Enhancement A suggestion for improvement. label Dec 3, 2024
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

No branches or pull requests

1 participant