From 4b29d5e228f82f70344c9a26d302cdb73cc8b570 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Tue, 26 Feb 2019 16:41:17 +0000 Subject: [PATCH] Clarify finding first non-null field error --- src/components/structures/auth/Registration.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/structures/auth/Registration.js b/src/components/structures/auth/Registration.js index b00c0c193f..b5707f0136 100644 --- a/src/components/structures/auth/Registration.js +++ b/src/components/structures/auth/Registration.js @@ -289,8 +289,11 @@ module.exports = React.createClass({ }, onFormValidationChange: function(fieldErrors) { - // Find the first error and show that. - const errCode = Object.values(fieldErrors).find(value => value); + // `fieldErrors` is an object mapping field IDs to error codes when there is an + // error or `null` for no error, so the values array will be something like: + // `[ null, "RegistrationForm.ERR_PASSWORD_MISSING", null]` + // Find the first non-null error code and show that. + const errCode = Object.values(fieldErrors).find(value => !!value); if (!errCode) { this.setState({ errorText: null,