1
0
mirror of https://github.com/EGroupware/egroupware.git synced 2024-12-30 18:49:24 +01:00

Et2Email: Fix placeholder not allowed

This commit is contained in:
nathan 2024-01-11 14:15:19 -07:00
parent 97be3be97a
commit 57c76e9840
2 changed files with 37 additions and 2 deletions
api/js/etemplate/Et2Email

View File

@ -253,6 +253,15 @@ export class Et2Email extends Et2InputWidget(LitElement) implements SearchMixinI
}
}
firstUpdated(changedProperties : PropertyValues)
{
super.firstUpdated(changedProperties);
// Make sure validators reflect allowPlaceholder, in case it's not caught by willUpdate()
this.defaultValidators = (<Array<Validator>>this.defaultValidators).filter(v => !(v instanceof IsEmail));
this.defaultValidators.push(new IsEmail(this.allowPlaceholder));
}
updated(changedProperties : PropertyValues)
{
super.updated(changedProperties);

View File

@ -117,6 +117,34 @@ describe("Email widget basics", () =>
assert.sameMembers(element.value, [value], "Valid email was not accepted on blur");
});
});
describe("Properties", async() =>
{
// Setup run before each test
beforeEach(before);
it("Allows placeholder", async() =>
{
const value = "{{placeholder}}";
element.allowPlaceholder = false;
await elementUpdated(element);
element.addAddress(value);
await elementUpdated(element);
assert.sameMembers(element.value, [], "Placeholder was accepted when not allowed");
element.allowPlaceholder = true;
await elementUpdated(element);
element.addAddress(value);
await elementUpdated(element);
assert.sameMembers(element.value, [value], "Placeholder was not accepted when allowed");
});
});
describe("Suggestions", () =>
{ // Setup run before each test
beforeEach(before);
@ -127,7 +155,6 @@ describe("Suggestions", () =>
// Start the search
element.focus();
element.startSearch();
debugger;
await waitForEvent(element, "sl-after-show");
// Click the first one
@ -199,7 +226,6 @@ describe("Tags", () =>
assert.sameMembers(element.value, ["two@example.com"], "Removing tag did not remove value");
assert.equal(element._tags.length, 1, "Removed tag is still there");
});
});
inputBasicTests(async() =>