@knovator/pagecreator-admin 1.6.9 → 1.6.10
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.
- package/index.cjs +11 -4
- package/index.js +11 -4
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -7201,6 +7201,7 @@ const WidgetForm = ({
|
|
|
7201
7201
|
const [blogCategories, setBlogCategories] = React.useState([]);
|
|
7202
7202
|
const [blogCategoriesLoading, setBlogCategoriesLoading] = React.useState(false);
|
|
7203
7203
|
const pagesLoadedRef = React.useRef(false);
|
|
7204
|
+
const blogCategoryInitialized = React.useRef(false);
|
|
7204
7205
|
React.useEffect(() => {
|
|
7205
7206
|
if (data && formState === 'UPDATE') {
|
|
7206
7207
|
const widgetType = widgetTypes.find(type => type.value === (data === null || data === void 0 ? void 0 : data.widgetType));
|
|
@@ -7265,20 +7266,21 @@ const WidgetForm = ({
|
|
|
7265
7266
|
}, [currentItemsType, baseUrl, token, widgetRoutesPrefix, blogCategories.length]);
|
|
7266
7267
|
// Set blog category and limit when editing a widget
|
|
7267
7268
|
React.useEffect(() => {
|
|
7268
|
-
if (formState === 'UPDATE' && data && currentItemsType === 'blog' && blogCategories.length > 0) {
|
|
7269
|
+
if (formState === 'UPDATE' && data && currentItemsType === 'blog' && blogCategories.length > 0 && !blogCategoryInitialized.current) {
|
|
7269
7270
|
// Set blog category if it exists in the data
|
|
7270
|
-
if (data.blogCategory
|
|
7271
|
+
if (data.blogCategory) {
|
|
7271
7272
|
const savedCategory = blogCategories.find(cat => cat.value === data.blogCategory);
|
|
7272
7273
|
if (savedCategory) {
|
|
7273
7274
|
setBlogCategory(savedCategory);
|
|
7275
|
+
blogCategoryInitialized.current = true;
|
|
7274
7276
|
}
|
|
7275
7277
|
}
|
|
7276
7278
|
// Set blog limit if it exists in the data
|
|
7277
|
-
if (data.blogLimit
|
|
7279
|
+
if (data.blogLimit) {
|
|
7278
7280
|
setBlogLimit(data.blogLimit);
|
|
7279
7281
|
}
|
|
7280
7282
|
}
|
|
7281
|
-
}, [formState, data, currentItemsType, blogCategories
|
|
7283
|
+
}, [formState, data, currentItemsType, blogCategories]);
|
|
7282
7284
|
// Clear collectionItems when using blog category/limit (server will handle fetching latest blogs)
|
|
7283
7285
|
React.useEffect(() => {
|
|
7284
7286
|
if (currentItemsType === 'blog') {
|
|
@@ -7295,8 +7297,13 @@ const WidgetForm = ({
|
|
|
7295
7297
|
setBlogCategory(null);
|
|
7296
7298
|
setBlogLimit(10);
|
|
7297
7299
|
setBlogCategories([]);
|
|
7300
|
+
blogCategoryInitialized.current = false;
|
|
7298
7301
|
}
|
|
7299
7302
|
}, [currentItemsType]);
|
|
7303
|
+
// Reset initialization flag when opening a different widget or changing form state
|
|
7304
|
+
React.useEffect(() => {
|
|
7305
|
+
blogCategoryInitialized.current = false;
|
|
7306
|
+
}, [data === null || data === void 0 ? void 0 : data._id, formState]);
|
|
7300
7307
|
// Watch blogLimit form value and update state
|
|
7301
7308
|
const watchedBlogLimit = watch('blogLimit');
|
|
7302
7309
|
React.useEffect(() => {
|
package/index.js
CHANGED
|
@@ -7189,6 +7189,7 @@ const WidgetForm = ({
|
|
|
7189
7189
|
const [blogCategories, setBlogCategories] = useState([]);
|
|
7190
7190
|
const [blogCategoriesLoading, setBlogCategoriesLoading] = useState(false);
|
|
7191
7191
|
const pagesLoadedRef = useRef(false);
|
|
7192
|
+
const blogCategoryInitialized = useRef(false);
|
|
7192
7193
|
useEffect(() => {
|
|
7193
7194
|
if (data && formState === 'UPDATE') {
|
|
7194
7195
|
const widgetType = widgetTypes.find(type => type.value === (data === null || data === void 0 ? void 0 : data.widgetType));
|
|
@@ -7253,20 +7254,21 @@ const WidgetForm = ({
|
|
|
7253
7254
|
}, [currentItemsType, baseUrl, token, widgetRoutesPrefix, blogCategories.length]);
|
|
7254
7255
|
// Set blog category and limit when editing a widget
|
|
7255
7256
|
useEffect(() => {
|
|
7256
|
-
if (formState === 'UPDATE' && data && currentItemsType === 'blog' && blogCategories.length > 0) {
|
|
7257
|
+
if (formState === 'UPDATE' && data && currentItemsType === 'blog' && blogCategories.length > 0 && !blogCategoryInitialized.current) {
|
|
7257
7258
|
// Set blog category if it exists in the data
|
|
7258
|
-
if (data.blogCategory
|
|
7259
|
+
if (data.blogCategory) {
|
|
7259
7260
|
const savedCategory = blogCategories.find(cat => cat.value === data.blogCategory);
|
|
7260
7261
|
if (savedCategory) {
|
|
7261
7262
|
setBlogCategory(savedCategory);
|
|
7263
|
+
blogCategoryInitialized.current = true;
|
|
7262
7264
|
}
|
|
7263
7265
|
}
|
|
7264
7266
|
// Set blog limit if it exists in the data
|
|
7265
|
-
if (data.blogLimit
|
|
7267
|
+
if (data.blogLimit) {
|
|
7266
7268
|
setBlogLimit(data.blogLimit);
|
|
7267
7269
|
}
|
|
7268
7270
|
}
|
|
7269
|
-
}, [formState, data, currentItemsType, blogCategories
|
|
7271
|
+
}, [formState, data, currentItemsType, blogCategories]);
|
|
7270
7272
|
// Clear collectionItems when using blog category/limit (server will handle fetching latest blogs)
|
|
7271
7273
|
useEffect(() => {
|
|
7272
7274
|
if (currentItemsType === 'blog') {
|
|
@@ -7283,8 +7285,13 @@ const WidgetForm = ({
|
|
|
7283
7285
|
setBlogCategory(null);
|
|
7284
7286
|
setBlogLimit(10);
|
|
7285
7287
|
setBlogCategories([]);
|
|
7288
|
+
blogCategoryInitialized.current = false;
|
|
7286
7289
|
}
|
|
7287
7290
|
}, [currentItemsType]);
|
|
7291
|
+
// Reset initialization flag when opening a different widget or changing form state
|
|
7292
|
+
useEffect(() => {
|
|
7293
|
+
blogCategoryInitialized.current = false;
|
|
7294
|
+
}, [data === null || data === void 0 ? void 0 : data._id, formState]);
|
|
7288
7295
|
// Watch blogLimit form value and update state
|
|
7289
7296
|
const watchedBlogLimit = watch('blogLimit');
|
|
7290
7297
|
useEffect(() => {
|