diff --git a/lib/build/emailpassword-shared7.js b/lib/build/emailpassword-shared7.js
index db90a2acb..018028673 100644
--- a/lib/build/emailpassword-shared7.js
+++ b/lib/build/emailpassword-shared7.js
@@ -425,7 +425,7 @@ function Label(_a) {
"div",
genericComponentOverrideContext.__assign(
{ "data-supertokens": "label" },
- { children: [t(value), showIsRequired && " *"] }
+ { children: [t(value), showIsRequired && value !== "" && " *"] }
)
);
}
diff --git a/lib/ts/recipe/emailpassword/components/library/label.tsx b/lib/ts/recipe/emailpassword/components/library/label.tsx
index 5096b636a..319b04760 100644
--- a/lib/ts/recipe/emailpassword/components/library/label.tsx
+++ b/lib/ts/recipe/emailpassword/components/library/label.tsx
@@ -26,7 +26,7 @@ export default function Label({ value, showIsRequired }: LabelProps): JSX.Elemen
return (
{t(value)}
- {showIsRequired && " *"}
+ {showIsRequired && value !== "" && " *"}
);
}
diff --git a/test/end-to-end/signup.test.js b/test/end-to-end/signup.test.js
index 1285e6ec0..b7cae7bc3 100644
--- a/test/end-to-end/signup.test.js
+++ b/test/end-to-end/signup.test.js
@@ -367,6 +367,12 @@ describe("SuperTokens SignUp", function () {
// check if checbox is loaded
const checkboxExists = await waitForSTElement(page, 'input[type="checkbox"]');
assert.ok(checkboxExists, "Checkbox exists");
+
+ // check if labels are loaded correctly
+ // non-optional field with empty labels should'nt show * sign
+ const expectedLabels = ["Email *", "Password *", "Select Dropdown", ""];
+ const labelNames = await getLabelsText(page);
+ assert.deepStrictEqual(labelNames, expectedLabels);
});
it("Should show error messages, based on optional flag", async function () {
diff --git a/test/end-to-end/thirdpartyemailpassword.test.js b/test/end-to-end/thirdpartyemailpassword.test.js
index bff13ae99..9779b00fd 100644
--- a/test/end-to-end/thirdpartyemailpassword.test.js
+++ b/test/end-to-end/thirdpartyemailpassword.test.js
@@ -46,6 +46,7 @@ import {
backendBeforeEach,
setSelectDropdownValue,
getInputField,
+ getLabelsText,
} from "../helpers";
import {
TEST_CLIENT_BASE_URL,
@@ -531,6 +532,12 @@ describe("SuperTokens Third Party Email Password", function () {
// check if checbox is loaded
const checkboxExists = await waitForSTElement(page, 'input[type="checkbox"]');
assert.ok(checkboxExists, "Checkbox exists");
+
+ // check if labels are loaded correctly
+ // non-optional field with empty labels should'nt show * sign
+ const expectedLabels = ["Email *", "Password *", "Select Dropdown", ""];
+ const labelNames = await getLabelsText(page);
+ assert.deepStrictEqual(labelNames, expectedLabels);
});
it("Should show error messages, based on optional flag", async function () {