From a2c0d7fae66b7b3f41f3995bc54270841cec2d39 Mon Sep 17 00:00:00 2001
From: Paul Gascou-Vaillancourt <paul.gascvail@gmail.com>
Date: Tue, 3 Jan 2023 07:37:25 -0500
Subject: [PATCH] Drop injects' default values

This removes default values from injected properties within the
`NotificationEmailListboxInput` component. Those were converted from
props to injects late in the initial implementation and the default
values had been preserved. However, it seems like an injected prop only
falls back to its default value if the property isn't provided at all.
If the property is provided but is `undefined`, that's used as the
prop's value, which caused an issue with the input's default value which
needs to be an empty string and not `undefined`.

Changelog: fixed
---
 .../notification_email_listbox_input.vue      | 26 +------------------
 app/assets/javascripts/notifications/index.js |  2 +-
 2 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/app/assets/javascripts/notifications/components/notification_email_listbox_input.vue b/app/assets/javascripts/notifications/components/notification_email_listbox_input.vue
index c58f4856d44e4..5d5524deb0dfd 100644
--- a/app/assets/javascripts/notifications/components/notification_email_listbox_input.vue
+++ b/app/assets/javascripts/notifications/components/notification_email_listbox_input.vue
@@ -5,31 +5,7 @@ export default {
   components: {
     ListboxInput,
   },
-  inject: {
-    label: {
-      from: 'label',
-      default: '',
-    },
-    name: {
-      from: 'name',
-    },
-    emails: {
-      from: 'emails',
-      default: () => [],
-    },
-    emptyValueText: {
-      from: 'emptyValueText',
-      required: true,
-    },
-    value: {
-      from: 'value',
-      default: '',
-    },
-    disabled: {
-      from: 'disabled',
-      default: false,
-    },
-  },
+  inject: ['label', 'name', 'emails', 'emptyValueText', 'value', 'disabled'],
   data() {
     return {
       selected: this.value,
diff --git a/app/assets/javascripts/notifications/index.js b/app/assets/javascripts/notifications/index.js
index 42271b44e7c32..1395084f68c46 100644
--- a/app/assets/javascripts/notifications/index.js
+++ b/app/assets/javascripts/notifications/index.js
@@ -10,7 +10,7 @@ const initNotificationEmailListboxInputs = () => {
   const els = [...document.querySelectorAll('.js-notification-email-listbox-input')];
 
   els.forEach((el, index) => {
-    const { label, name, emptyValueText, value } = el.dataset;
+    const { label, name, emptyValueText, value = '' } = el.dataset;
 
     return new Vue({
       el,
-- 
GitLab