Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3096] Content-Create-Item: Added an identifier when user inputs meta… #3110

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from

Conversation

geodem127
Copy link
Contributor

… discription manualy

@@ -46,7 +46,12 @@ export default memo(function Editor({
const dispatch = useDispatch();
const isNewItem = itemZUID.slice(0, 3) === "new";
const { data: fields } = useGetContentModelFieldsQuery(modelZUID);
const { data, web } = useSelector(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The item is already in scope e.g the item prop. Don't see the reason for this selector

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I totally missed it. Updated this already

@@ -355,6 +361,32 @@ export default memo(function Editor({
}
}, [isNewItem, setIsLoaded, applyDefaultValuesToItemData]);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is really hard to follow. I would expect this logic to exist within the call stack of the change handler. But will let @finnar-bin weigh in as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I kind of agree with what @agalin920 commented.

Correct me if I'm wrong but wouldn't it be easier to just have 3 states (metaDescription, og_description and tc_description) that holds a boolean value, then set the state to true if the user has done a manual input on those fields (the field names are static so it should be easy to find out through the onChange handler if any of those fields have been manually updated). Then on these lines do not do the dispatch if the state is true since that would mean the user has performed a manual update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@finnar-bin , this would be the case if "description" and "metaDescription" consistently matched after the page load (without persisting any data). I had a similar thought initially, but things get more complex when the user refreshes the page or navigates to a different one. In such scenarios, metaDescription retains its previous value even if the meta component hasn’t fully loaded in the view, causing it to mistakenly assume that metaDescription has changed. That said, I might have missed something, so a walkthrough would be helpful to clarify.

useEffect(() => {
if (!isNewItem) return;
const isMetaDescriptionInitState = metaDescription === web?.metaDescription;
const isDescriptionChanged = data?.description !== web?.metaDescription;
Copy link
Contributor

@agalin920 agalin920 Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful here, this is incorrect. Data key is the set fields on a model. Therefore data.description is not a guaranteed field nor is the set logic looking for this field. Fields are defined by the user e.g myDescription, someDescription, mySecondTextField etc...

@@ -355,6 +361,32 @@ export default memo(function Editor({
}
}, [isNewItem, setIsLoaded, applyDefaultValuesToItemData]);

useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I kind of agree with what @agalin920 commented.

Correct me if I'm wrong but wouldn't it be easier to just have 3 states (metaDescription, og_description and tc_description) that holds a boolean value, then set the state to true if the user has done a manual input on those fields (the field names are static so it should be easy to find out through the onChange handler if any of those fields have been manually updated). Then on these lines do not do the dispatch if the state is true since that would mean the user has performed a manual update.

@geodem127 geodem127 force-pushed the fix/3096-Content-Create-Item-Updated branch from bf309c8 to b0f7cc5 Compare January 3, 2025 05:27
@geodem127 geodem127 requested a review from finnar-bin January 6, 2025 19:38
@geodem127 geodem127 requested a review from agalin920 January 16, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content: Create Item - System should not override custom Meta Description set by user
3 participants