Skip to content

Commit

Permalink
fix: issue #346 fetching default title (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyp3rius authored Jun 8, 2023
1 parent eaa8493 commit f29aeab
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Complete installation requirements are exact same as for Strapi itself and can b

**Supported Strapi versions**:

- Strapi v4.10.6 (recently tested)
- Strapi v4.11.0 (recently tested)
- Strapi v4.x

> This plugin is designed for **Strapi v4** and is not working with v3.x. To get version for **Strapi v3** install version [v1.x](https://github.com/VirtusLab-Open-Source/strapi-plugin-navigation/tree/strapi-v3).
Expand Down
12 changes: 8 additions & 4 deletions admin/src/pages/View/components/NavigationItemForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ const NavigationItemForm: React.FC<NavigationItemFormProps> = ({

const getDefaultTitle =
useCallback((related: string | undefined, relatedType: string | undefined, isSingleSelected: boolean) => {
let selectedEntity;
if (isSingleSelected) {
return contentTypes.find(_ => _.uid === relatedType)?.label
selectedEntity = contentTypeEntities.find(_ => (_.uid === relatedType) || (_.__collectionUid === relatedType));
if (!selectedEntity) {
return contentTypes.find(_ => _.uid === relatedType)?.label
}
} else {
return extractRelatedItemLabel({
selectedEntity = {
...contentTypeEntities.find(_ => _.id === related),
__collectionUid: relatedType
}, contentTypesNameFields, { contentTypes });
};
}

return extractRelatedItemLabel(selectedEntity, contentTypesNameFields, { contentTypes });
}, [contentTypeEntities, contentTypesNameFields, contentTypes]);

const sanitizePayload = async (slugify: Slugify, payload: RawFormPayload, data: Partial<NavigationItemFormData>): Promise<SanitizedFormPayload> => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "strapi-plugin-navigation",
"version": "2.2.9",
"version": "2.2.10",
"description": "Strapi - Navigation plugin",
"strapi": {
"name": "navigation",
Expand All @@ -23,7 +23,7 @@
},
"dependencies": {
"@sindresorhus/slugify": "1.1.0",
"@strapi/utils": "^4.10.6",
"@strapi/utils": "^4.11.0",
"lodash": "^4.17.11",
"pluralize": "^8.0.0",
"react": "^17.0.2",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1205,10 +1205,10 @@
p-map "4.0.0"
yup "0.32.9"

"@strapi/utils@^4.10.6":
version "4.10.6"
resolved "https://registry.yarnpkg.com/@strapi/utils/-/utils-4.10.6.tgz#b32a2382fdcaaa04de0a681aeece8ad3bbd7ef2c"
integrity sha512-X9dNy31mhTvoeoLScGGw722N2r/bTaSp8wU8ryMvnooLYKcbw7GOcU6rSM7k5WNQToWziaditA2Vx34nZNdUsw==
"@strapi/utils@^4.11.0":
version "4.11.0"
resolved "https://registry.yarnpkg.com/@strapi/utils/-/utils-4.11.0.tgz#2f123cd0049028d92f7ecba0b63bb853411401f6"
integrity sha512-0k+0igoH/LRlxhKQDr7t6w1lg+7mQV0CYt0eNFNPC8u8o6SFA0l57jgYUZYU7q/jxofD4xrZituEEy5GQXaTEA==
dependencies:
"@sindresorhus/slugify" "1.1.0"
date-fns "2.30.0"
Expand Down

0 comments on commit f29aeab

Please sign in to comment.