From 33a939b1c6efe60b38c9d3ea9b968e27a63b923d Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Wed, 10 Jan 2024 17:18:21 -0700 Subject: [PATCH 1/2] - fallback if acfFieldType is not there --- wp-blocks/AcfFieldTypeConfigurationBlock.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wp-blocks/AcfFieldTypeConfigurationBlock.js b/wp-blocks/AcfFieldTypeConfigurationBlock.js index 9fb3ca5..d9f0d56 100644 --- a/wp-blocks/AcfFieldTypeConfigurationBlock.js +++ b/wp-blocks/AcfFieldTypeConfigurationBlock.js @@ -53,6 +53,9 @@ function generateJSONTabContent(data) { function TabContent({ fieldTypeConfigurationBlockFields, uniqueId, format }) { const { acfFieldType } = fieldTypeConfigurationBlockFields; + if ( ! acfFieldType ) { + return null; + }; const data = generateData(uniqueId, acfFieldType); return format === 'php' ? generatePHPTabContent(data) : generateJSONTabContent(data); @@ -60,6 +63,9 @@ function TabContent({ fieldTypeConfigurationBlockFields, uniqueId, format }) { export function AcfFieldTypeConfigurationBlock({ fieldTypeConfigurationBlockFields }) { const { acfFieldType } = fieldTypeConfigurationBlockFields; + if ( ! acfFieldType ) { + return null; + }; const [uniqueId, setUniqueId] = useState(''); useEffect(() => { From 2373213d4335f795d921c1ae622deb5422ff2da2 Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Wed, 10 Jan 2024 17:22:18 -0700 Subject: [PATCH 2/2] - return helpful feedback instead of returning null --- wp-blocks/AcfFieldTypeConfigurationBlock.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/wp-blocks/AcfFieldTypeConfigurationBlock.js b/wp-blocks/AcfFieldTypeConfigurationBlock.js index d9f0d56..be77ab5 100644 --- a/wp-blocks/AcfFieldTypeConfigurationBlock.js +++ b/wp-blocks/AcfFieldTypeConfigurationBlock.js @@ -53,9 +53,7 @@ function generateJSONTabContent(data) { function TabContent({ fieldTypeConfigurationBlockFields, uniqueId, format }) { const { acfFieldType } = fieldTypeConfigurationBlockFields; - if ( ! acfFieldType ) { - return null; - }; + const data = generateData(uniqueId, acfFieldType); return format === 'php' ? generatePHPTabContent(data) : generateJSONTabContent(data); @@ -64,7 +62,13 @@ function TabContent({ fieldTypeConfigurationBlockFields, uniqueId, format }) { export function AcfFieldTypeConfigurationBlock({ fieldTypeConfigurationBlockFields }) { const { acfFieldType } = fieldTypeConfigurationBlockFields; if ( ! acfFieldType ) { - return null; + return ( + + + Field Type Config has not been configured for this field type + + + ); }; const [uniqueId, setUniqueId] = useState('');