FIX: Trim whitespace on email field for invites (#20547)

If the whitespace isn't trimmed from the input field the email is
considered invalid, and the button remains greyed out. We should handle
removing any trailing whitespace and not rely on the user trying to see
it themselves.
This commit is contained in:
Blake Erickson 2023-03-06 17:39:59 -07:00 committed by GitHub
parent 15cf62411a
commit b4528b9e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -34,12 +34,12 @@ export default Controller.extend(
@discourseComputed("buffered.emailOrDomain")
isEmail(emailOrDomain) {
return emailValid(emailOrDomain);
return emailValid(emailOrDomain?.trim());
},
@discourseComputed("buffered.emailOrDomain")
isDomain(emailOrDomain) {
return hostnameValid(emailOrDomain);
return hostnameValid(emailOrDomain?.trim());
},
isLink: not("isEmail"),
@ -83,9 +83,9 @@ export default Controller.extend(
if (data.emailOrDomain) {
if (emailValid(data.emailOrDomain)) {
data.email = data.emailOrDomain;
data.email = data.emailOrDomain?.trim();
} else if (hostnameValid(data.emailOrDomain)) {
data.domain = data.emailOrDomain;
data.domain = data.emailOrDomain?.trim();
}
delete data.emailOrDomain;
}

View File

@ -155,7 +155,7 @@ acceptance("Invites - Email Invites", function (needs) {
"sends skip_email to server"
);
await fillIn("#invite-email", "test2@example.com");
await fillIn("#invite-email", "test2@example.com ");
assert.ok(exists(".send-invite"), "shows save and send email button");
await click(".send-invite");
assert.ok(