},
deleteDisabled() {
- return !this.containsNoWhitespace(this.email)
+ if (this.primary) {
+ return this.email === ''
+ }
+ return this.email !== '' && !this.isValid()
},
deleteEmailLabel() {
},
},
+ mounted() {
+ if (this.initialEmail === '') {
+ this.$nextTick(() => this.$refs.email?.focus())
+ }
+ },
+
methods: {
onEmailChange(e) {
this.$emit('update:email', e.target.value)
},
debounceEmailChange: debounce(async function() {
- if ((this.$refs.email?.checkValidity() && this.containsNoWhitespace(this.email)) || this.email === '') {
+ if (this.$refs.email?.checkValidity() || this.email === '') {
if (this.primary) {
await this.updatePrimaryEmail()
} else {
- if (this.initialEmail && this.email === '') {
- await this.deleteAdditionalEmail()
- } else if (this.initialEmail === '') {
- await this.addAdditionalEmail()
- } else {
- await this.updateAdditionalEmail()
+ if (this.email) {
+ if (this.initialEmail === '') {
+ await this.addAdditionalEmail()
+ } else {
+ await this.updateAdditionalEmail()
+ }
}
}
}
}
},
- containsNoWhitespace(string) {
- return /^\S+$/.test(string)
+ isValid() {
+ return /^\S+$/.test(this.email)
},
handleDeleteAdditionalEmail(status) {
class="section"
@submit.stop.prevent="() => {}">
<HeaderBar
- :can-edit-emails="isDisplayNameChangeSupported"
+ :can-edit-emails="displayNameChangeSupported"
:is-valid-form="isValidForm"
:scope.sync="primaryEmail.scope"
@addAdditionalEmail="onAddAdditionalEmail" />
- <template v-if="isDisplayNameChangeSupported">
+ <template v-if="displayNameChangeSupported">
<Email
:primary="true"
:scope.sync="primaryEmail.scope"
data() {
return {
additionalEmails,
+ displayNameChangeSupported,
primaryEmail,
isValidForm: true,
}
},
computed: {
- isDisplayNameChangeSupported() {
- return displayNameChangeSupported
- },
-
primaryEmailValue: {
get() {
return this.primaryEmail.value
onDeleteAdditionalEmail(index) {
this.$delete(this.additionalEmails, index)
+ this.$nextTick(() => this.updateFormValidity())
},
async onUpdateEmail() {