diff --git a/src/app/organisms/profile-editor/ProfileEditor.jsx b/src/app/organisms/profile-editor/ProfileEditor.jsx index 9dd308a4..a124acaa 100644 --- a/src/app/organisms/profile-editor/ProfileEditor.jsx +++ b/src/app/organisms/profile-editor/ProfileEditor.jsx @@ -37,20 +37,27 @@ function ProfileEditor({ } function saveDisplayName() { - if (displayNameRef.current.value !== null && displayNameRef.current.value !== '') { - mx.setDisplayName(displayNameRef.current.value); - username = displayNameRef.current.value; + const newDisplayName = displayNameRef.current.value; + if (newDisplayName !== null && newDisplayName !== username) { + mx.setDisplayName(newDisplayName); + username = newDisplayName; setDisabled(true); } } - // Enables/disables button depending on if the typed displayname is different than the current. function onDisplayNameInputChange() { - setDisabled((username === displayNameRef.current.value) || displayNameRef.current.value === '' || displayNameRef.current.value == null); + setDisabled(username === displayNameRef.current.value || displayNameRef.current.value == null); + } + function cancelDisplayNameChanges() { + displayNameRef.current.value = username; + onDisplayNameInputChange(); } return ( -