fix: recall parsing for headlines with empty strings (#6131)

This commit is contained in:
Dhruwang Jariwala
2025-07-01 13:46:14 +05:30
committed by GitHub
parent da72101320
commit d10cff917d
3 changed files with 5 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ export function Headline({ headline, questionId, required = true, alignTextCente
<div
className={`fb-flex fb-items-center ${alignTextCenter ? "fb-justify-center" : "fb-justify-between"}`}
dir="auto">
{headline}
<p>{headline}</p>
{!required && (
<span
className="fb-text-heading fb-mx-2 fb-self-start fb-text-sm fb-font-normal fb-leading-7 fb-opacity-60"

View File

@@ -7,6 +7,9 @@ describe("i18n", () => {
test("should return empty string for undefined value", () => {
expect(getLocalizedValue(undefined, "en")).toBe("");
});
test("should return empty string for empty string", () => {
expect(getLocalizedValue({ default: "" }, "en")).toBe("");
});
test("should return empty string for non-i18n string", () => {
expect(getLocalizedValue("not an i18n string" as any, "en")).toBe("");

View File

@@ -10,7 +10,7 @@ export const getLocalizedValue = (value: TI18nString | undefined, languageId: st
return "";
}
if (isI18nObject(value)) {
if (value[languageId]) {
if (typeof value[languageId] === "string") {
return value[languageId];
}
return value.default;