mirror of
https://github.com/lingble/chatwoot.git
synced 2025-10-30 02:32:29 +00:00
# Pull Request Template ## Description This PR fixes an issue where users are unable to delete an inbox because the delete confirmation button remains disabled. ### Cause Inboxes created with leading or trailing spaces in their names failed the confirmation check. During deletion, the confirmation modal compared the raw user input with the stored inbox name. Because whitespace was not normalized, the values did not match exactly, causing the delete button to remain inactive even when the correct name was entered. ### Solution The validation logic now trims whitespace from both the input and stored value before comparison. This ensures inbox names with accidental spaces are handled correctly, and the delete button works as expected in all cases. Fixes https://linear.app/chatwoot/issue/CW-5659/confirmation-button-greyed-out-randomly-when-deleting-inbox-from-inbox ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? **Steps to Reproduce** 1. Create an inbox with leading or trailing whitespace in its name. 2. Save and complete the inbox creation process. 3. Go to the inbox list and try deleting the inbox by entering the name without the whitespace in the confirmation modal. 4. Now you can't able to delete the inbox. ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
93 lines
2.2 KiB
Vue
93 lines
2.2 KiB
Vue
<script>
|
|
import { required } from '@vuelidate/validators';
|
|
import { useVuelidate } from '@vuelidate/core';
|
|
import Modal from '../../Modal.vue';
|
|
|
|
import NextButton from 'dashboard/components-next/button/Button.vue';
|
|
|
|
export default {
|
|
components: {
|
|
Modal,
|
|
NextButton,
|
|
},
|
|
props: {
|
|
show: { type: Boolean, default: false },
|
|
title: { type: String, default: '' },
|
|
message: { type: String, default: '' },
|
|
confirmText: { type: String, default: '' },
|
|
rejectText: { type: String, default: '' },
|
|
confirmValue: { type: String, default: '' },
|
|
confirmPlaceHolderText: { type: String, default: '' },
|
|
},
|
|
emits: ['onClose', 'onConfirm', 'update:show'],
|
|
setup() {
|
|
return { v$: useVuelidate() };
|
|
},
|
|
data() {
|
|
return {
|
|
value: '',
|
|
};
|
|
},
|
|
validations: {
|
|
value: {
|
|
required,
|
|
isEqual(value) {
|
|
// Trim whitespace from both input and target values
|
|
const normalizedInput = (value || '').trim();
|
|
const normalizedTarget = (this.confirmValue || '').trim();
|
|
return normalizedInput === normalizedTarget;
|
|
},
|
|
},
|
|
},
|
|
computed: {
|
|
localShow: {
|
|
get() {
|
|
return this.show;
|
|
},
|
|
set(value) {
|
|
this.$emit('update:show', value);
|
|
},
|
|
},
|
|
},
|
|
methods: {
|
|
closeModal() {
|
|
this.value = '';
|
|
this.$emit('onClose');
|
|
},
|
|
onConfirm() {
|
|
this.$emit('onConfirm');
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<Modal v-model:show="localShow" :on-close="closeModal">
|
|
<woot-modal-header :header-title="title" :header-content="message" />
|
|
<form @submit.prevent="onConfirm">
|
|
<woot-input
|
|
v-model="value"
|
|
type="text"
|
|
:class="{ error: v$.value.$error }"
|
|
:placeholder="confirmPlaceHolderText"
|
|
@blur="v$.value.$touch"
|
|
/>
|
|
<div class="flex items-center justify-end gap-2">
|
|
<NextButton
|
|
faded
|
|
slate
|
|
type="reset"
|
|
:label="rejectText"
|
|
@click.prevent="closeModal"
|
|
/>
|
|
<NextButton
|
|
ruby
|
|
type="submit"
|
|
:label="confirmText"
|
|
:disabled="v$.value.$invalid"
|
|
/>
|
|
</div>
|
|
</form>
|
|
</Modal>
|
|
</template>
|