Skip to content

Commit

Permalink
feat: prevent hyphen and space on template name paste
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobernardoaf committed Nov 6, 2023
1 parent 83e861f commit 871d80d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/whatsAppTemplates/FormTabContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<div class="form-tab-content--inline">
<unnnic-input
class="form-tab-content__input--name"
ref="nameInput"
:disabled="disableInputs || formMode !== 'create'"
:value="templateForm.name"
@input="handleTemplateFormInput({ fieldName: 'name', fieldValue: $event })"
Expand Down Expand Up @@ -174,6 +175,18 @@
},
};
},
mounted() {
const nativeNameInput = this.$refs.nameInput.$el.querySelector('input');
nativeNameInput.addEventListener('paste', (event) => {
event.preventDefault();
nativeNameInput.value = event.clipboardData
.getData('Text')
.replaceAll(' ', '_')
.replaceAll('-', '_')
.toLowerCase();
});
},
computed: {
...mapGetters('WhatsApp', ['templateTranslationCurrentForm']),
...mapState('WhatsApp', ['templateForm', 'whatsAppTemplates']),
Expand Down

0 comments on commit 871d80d

Please sign in to comment.