Skip to content

Commit e7e837d

Browse files
committed
Use unique key to prevent email component reuse
Signed-off-by: Christopher Ng <chrng8@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com> (cherry picked from commit fc03a93)
1 parent 3008908 commit e7e837d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

apps/settings/src/components/PersonalInfo/EmailSection/Email.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
<Actions
5151
class="actions-email"
5252
:aria-label="t('settings', 'Email options')"
53-
:disabled="deleteDisabled"
5453
:force-menu="true">
5554
<ActionButton
5655
:aria-label="deleteEmailLabel"

apps/settings/src/components/PersonalInfo/EmailSection/EmailSection.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
<span v-else>
4242
{{ primaryEmail.value || t('settings', 'No email address set') }}
4343
</span>
44+
<!-- TODO use unique key for additional email when uniqueness can be guaranteed, see https://github.com/nextcloud/server/issues/26866 -->
4445
<Email v-for="(additionalEmail, index) in additionalEmails"
45-
:key="index"
46+
:key="additionalEmail.key"
4647
:index="index"
4748
:scope.sync="additionalEmail.scope"
4849
:email.sync="additionalEmail.value"
@@ -77,7 +78,7 @@ export default {
7778
7879
data() {
7980
return {
80-
additionalEmails,
81+
additionalEmails: additionalEmails.map(properties => ({ ...properties, key: this.generateUniqueKey() })),
8182
displayNameChangeSupported,
8283
primaryEmail,
8384
isValidForm: true,
@@ -110,7 +111,7 @@ export default {
110111
methods: {
111112
onAddAdditionalEmail() {
112113
if (this.$refs.form?.checkValidity()) {
113-
this.additionalEmails.push({ value: '', scope: DEFAULT_ADDITIONAL_EMAIL_SCOPE })
114+
this.additionalEmails.push({ value: '', scope: DEFAULT_ADDITIONAL_EMAIL_SCOPE, key: this.generateUniqueKey() })
114115
this.$nextTick(() => this.updateFormValidity())
115116
}
116117
},
@@ -172,6 +173,10 @@ export default {
172173
updateFormValidity() {
173174
this.isValidForm = this.$refs.form?.checkValidity()
174175
},
176+
177+
generateUniqueKey() {
178+
return Math.random().toString(36).substring(2)
179+
},
175180
},
176181
}
177182
</script>

0 commit comments

Comments
 (0)