mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-06 05:40:02 -06:00
fix: recall parsing for headlines with empty strings (#6131)
This commit is contained in:
committed by
GitHub
parent
da72101320
commit
d10cff917d
@@ -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"
|
||||
|
||||
@@ -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("");
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user