Skip to content

Conversation

@geodem127
Copy link
Contributor

Root Cause:

The relational field inherits the language selection from when the source item was originally created.

Fix:

Implemented logic to retrieve content items localized to the currently selected language.

Loom.Message.-.22.October.2025.1.mp4

@geodem127 geodem127 self-assigned this Oct 22, 2025
@geodem127 geodem127 added the bug Something isn't working label Oct 22, 2025
const [prevFirstContentFieldValue, setPrevFirstContentFieldValue] =
useState(null);
const languages = useSelector((state) => state.languages);
const contentItems = useSelector((state) => state.content);
Copy link
Contributor

@agalin920 agalin920 Oct 22, 2025

Choose a reason for hiding this comment

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

This is a pretty significant selector that will cause the whole Editor to re-render on content change. We should move it as low as possible in the component tree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed contentItems selector

Copy link
Contributor

@agalin920 agalin920 left a comment

Choose a reason for hiding this comment

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

.

<div className={styles.Fields}>
{activeFields?.map((field) => {
const fieldItem = contentItems?.[item?.data?.[field.name]];
const fieldValue = ["one_to_one", "one_to_many"].includes(
Copy link
Contributor

@agalin920 agalin920 Oct 22, 2025

Choose a reason for hiding this comment

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

Related to previous comment. Would it not be a better idea to add this business logic in the relationship field component itself specifically in these types case blocks? since it only relates to specific field types and is much lower in the component tree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. That's a much better approach. I've moved the locale-update logic into the relationship field component as suggested.

@geodem127 geodem127 requested a review from agalin920 October 29, 2025 13:55
@@ -1,5 +1,5 @@
import { memo, useCallback, useEffect, useMemo, useState } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
Copy link
Contributor

Choose a reason for hiding this comment

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

unused import

]);

useEffect(() => {
updateItemLocale();
Copy link
Contributor

@agalin920 agalin920 Oct 29, 2025

Choose a reason for hiding this comment

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

This seems like a very hacky solution to this. If im reading this correctly you are changing the content's state and then manually unmarking it as dirty on mount? Are we also changing values? If so why? We should not be doing any kind of content change that is not explicit by the user

A more holistic solution is when switching locale the value of the initial state should reflect the locale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The content of all locale items will be identical, as they inherit the same content upon creation.

I’m not sure if we have control over that behavior on the frontend.

@agalin920
Copy link
Contributor

Based on discussions @geodem127 we should close or mark the pr as draft. Don't want this accidentally merged in

@geodem127 geodem127 marked this pull request as draft November 5, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content - Item with relational field not reflecting correct locale when switch to other language version

3 participants