@webbio/strapi-plugin-page-builder 0.18.0-platform → 0.18.1-platform

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,7 @@ import { PAGE_TYPE_PAGE, PAGE_UID } from '../../../../../shared/utils/constants'
10
10
  import { usePlatformFormData } from '../../../utils/hooks/usePlatformFormData';
11
11
  import S from '../Details/styles';
12
12
  import { usePageTypeExists } from '../../../api/page-type-exists';
13
+ import { delay } from '../../../utils/delay';
13
14
 
14
15
  interface CollectionTypeSettingsProps {
15
16
  onlyPlatform?: boolean;
@@ -38,15 +39,26 @@ export const CollectionTypeSettings = ({ onlyPlatform }: CollectionTypeSettingsP
38
39
  }
39
40
  }, [modifiedData.page?.[0]]);
40
41
 
41
- useEffect(() => {
42
- if (isCreatingEntry) {
43
- onChange({
42
+ // Reset page link if creating entry
43
+ // Reason for the delay is explained in usePlatformFormData.ts
44
+ const resetPageLinkIfCreatingEntry = async () => {
45
+ if (!isCreatingEntry || (isCreatingEntry && !initialData.page)) return;
46
+
47
+ await delay(100);
48
+
49
+ onChange(
50
+ {
44
51
  target: {
45
52
  name: 'page',
46
53
  value: null
47
54
  }
48
- });
49
- }
55
+ },
56
+ false
57
+ );
58
+ };
59
+
60
+ useEffect(() => {
61
+ resetPageLinkIfCreatingEntry();
50
62
  }, []);
51
63
 
52
64
  return (
@@ -55,16 +55,6 @@ const PlatformFilteredSelectField = (props: IPlatformFilteredSelectFieldProps) =
55
55
  );
56
56
  };
57
57
 
58
- PlatformFilteredSelectField.defaultProps = {
59
- description: undefined,
60
- disabled: false,
61
- error: undefined,
62
- labelAction: undefined,
63
- placeholder: undefined,
64
- value: '',
65
- required: false
66
- };
67
-
68
58
  export default PlatformFilteredSelectField;
69
59
 
70
60
  const getLocalizedActionLabel = (actionLabel?: JSX.Element, layout?: Record<string, any>): JSX.Element | undefined => {
@@ -0,0 +1 @@
1
+ export const delay = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
@@ -4,6 +4,7 @@ import { Platform } from '../../api/platform';
4
4
  import { useDefaultPlatformFromLocalStorage } from './useDefaultPlatformFromLocalStorage';
5
5
  import { useGetPlatformRelation } from '../../api/platform-relation';
6
6
  import { PLATFORM_UID } from '../../../../shared/utils/constants';
7
+ import { delay } from '../delay';
7
8
 
8
9
  const usePlatformFormData = (form?: Record<string, any>, onPlatformChange?: (platform: Platform) => void) => {
9
10
  const { onChange, initialData, modifiedData, layout, isCreatingEntry } = form || {};
@@ -77,7 +78,3 @@ const usePlatformFormData = (form?: Record<string, any>, onPlatformChange?: (pla
77
78
  };
78
79
 
79
80
  export { usePlatformFormData };
80
-
81
- function delay(ms: number) {
82
- return new Promise((resolve) => setTimeout(resolve, ms));
83
- }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.18.0-platform",
3
+ "version": "0.18.1-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",