diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js index fe776ac871..6e13e2bffe 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/Value.js @@ -16,7 +16,12 @@ const Value = ({ children, ...props }) => { category, schema: { name }, } = selectedComponent; - + const { + selectProps: { componentCategory, componentName, isCreatingComponent }, + } = props; + console.log({ props }); + const displayedCategory = isCreatingComponent ? componentCategory : category; + const displayedName = isCreatingComponent ? componentName : name; const style = { color: '#333740' }; return ( @@ -24,10 +29,10 @@ const Value = ({ children, ...props }) => { {!!value && ( <> - {upperFirst(category)} + {upperFirst(displayedCategory)}  —  - {name} + {displayedName} )} @@ -36,10 +41,20 @@ const Value = ({ children, ...props }) => { Value.defaultProps = { children: null, + selectProps: { + componentCategory: null, + componentName: null, + isCreatingComponent: false, + }, }; Value.propTypes = { children: PropTypes.string, + selectProps: PropTypes.shape({ + componentCategory: PropTypes.string, + componentName: PropTypes.string, + isCreatingComponent: PropTypes.bool, + }), }; export default Value; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js index 129b12f805..2c173782d0 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/ComponentSelect/index.js @@ -4,7 +4,15 @@ import PropTypes from 'prop-types'; import MenuList from './MenuList'; import Value from './Value'; -const ComponentSelect = ({ onChange, name, value, styles }) => { +const ComponentSelect = ({ + componentCategoryNeededForAddingAfieldWhileCreatingAComponent, + componentNameNeededForAddingAfieldWhileCreatingAComponent, + isCreatingComponentWhileAddingAField, + onChange, + name, + value, + styles, +}) => { // Create a ref in order to access the StateManager // So we can close the menu after clicking on a menu item // This allows us to get rid of the menuIsOpen state management @@ -22,6 +30,12 @@ const ComponentSelect = ({ onChange, name, value, styles }) => { return (