fix: Editor toggle button not showing the correct active mode (#12350)

This commit is contained in:
Sivin Varghese
2025-09-09 17:22:35 +05:30
committed by GitHub
parent 0e1c3c5596
commit b344bac1ba
4 changed files with 30 additions and 10 deletions

View File

@@ -8,6 +8,10 @@ const props = defineProps({
type: String, type: String,
default: REPLY_EDITOR_MODES.REPLY, default: REPLY_EDITOR_MODES.REPLY,
}, },
disabled: {
type: Boolean,
default: false,
},
}); });
defineEmits(['toggleMode']); defineEmits(['toggleMode']);
@@ -20,9 +24,12 @@ const privateModeSize = useElementSize(wootEditorPrivateMode);
/** /**
* Computed boolean indicating if the editor is in private note mode * Computed boolean indicating if the editor is in private note mode
* When disabled, always show NOTE mode regardless of actual mode prop
* @type {ComputedRef<boolean>} * @type {ComputedRef<boolean>}
*/ */
const isPrivate = computed(() => props.mode === REPLY_EDITOR_MODES.NOTE); const isPrivate = computed(() => {
return props.disabled || props.mode === REPLY_EDITOR_MODES.NOTE;
});
/** /**
* Computes the width of the sliding background chip in pixels * Computes the width of the sliding background chip in pixels
@@ -53,6 +60,10 @@ const translateValue = computed(() => {
<template> <template>
<button <button
class="flex items-center w-auto h-8 p-1 transition-all border rounded-full bg-n-alpha-2 group relative duration-300 ease-in-out z-0" class="flex items-center w-auto h-8 p-1 transition-all border rounded-full bg-n-alpha-2 group relative duration-300 ease-in-out z-0"
:disabled="disabled"
:class="{
'cursor-not-allowed': disabled,
}"
@click="$emit('toggleMode')" @click="$emit('toggleMode')"
> >
<div ref="wootEditorReplyMode" class="flex items-center gap-1 px-2 z-20"> <div ref="wootEditorReplyMode" class="flex items-center gap-1 px-2 z-20">
@@ -62,7 +73,10 @@ const translateValue = computed(() => {
{{ $t('CONVERSATION.REPLYBOX.PRIVATE_NOTE') }} {{ $t('CONVERSATION.REPLYBOX.PRIVATE_NOTE') }}
</div> </div>
<div <div
class="absolute shadow-sm rounded-full h-6 w-[var(--chip-width)] transition-all duration-300 ease-in-out translate-x-[var(--translate-x)] rtl:translate-x-[var(--rtl-translate-x)] bg-n-solid-1" class="absolute shadow-sm rounded-full h-6 w-[var(--chip-width)] ease-in-out translate-x-[var(--translate-x)] rtl:translate-x-[var(--rtl-translate-x)] bg-n-solid-1"
:class="{
'transition-all duration-300': !disabled,
}"
:style="{ :style="{
'--chip-width': width, '--chip-width': width,
'--translate-x': translateValue, '--translate-x': translateValue,

View File

@@ -10,7 +10,6 @@ import { getAllowedFileTypesByChannel } from '@chatwoot/utils';
import { ALLOWED_FILE_TYPES } from 'shared/constants/messages'; import { ALLOWED_FILE_TYPES } from 'shared/constants/messages';
import VideoCallButton from '../VideoCallButton.vue'; import VideoCallButton from '../VideoCallButton.vue';
import AIAssistanceButton from '../AIAssistanceButton.vue'; import AIAssistanceButton from '../AIAssistanceButton.vue';
import { REPLY_EDITOR_MODES } from './constants';
import { INBOX_TYPES } from 'dashboard/helper/inbox'; import { INBOX_TYPES } from 'dashboard/helper/inbox';
import { mapGetters } from 'vuex'; import { mapGetters } from 'vuex';
import NextButton from 'dashboard/components-next/button/Button.vue'; import NextButton from 'dashboard/components-next/button/Button.vue';
@@ -20,9 +19,9 @@ export default {
components: { NextButton, FileUpload, VideoCallButton, AIAssistanceButton }, components: { NextButton, FileUpload, VideoCallButton, AIAssistanceButton },
mixins: [inboxMixin], mixins: [inboxMixin],
props: { props: {
mode: { isNote: {
type: String, type: Boolean,
default: REPLY_EDITOR_MODES.REPLY, default: false,
}, },
onSend: { onSend: {
type: Function, type: Function,
@@ -168,9 +167,6 @@ export default {
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount', isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
uiFlags: 'integrations/getUIFlags', uiFlags: 'integrations/getUIFlags',
}), }),
isNote() {
return this.mode === REPLY_EDITOR_MODES.NOTE;
},
wrapClass() { wrapClass() {
return { return {
'is-note-mode': this.isNote, 'is-note-mode': this.isNote,

View File

@@ -15,6 +15,10 @@ export default {
type: String, type: String,
default: REPLY_EDITOR_MODES.REPLY, default: REPLY_EDITOR_MODES.REPLY,
}, },
isReplyRestricted: {
type: Boolean,
default: false,
},
isMessageLengthReachingThreshold: { isMessageLengthReachingThreshold: {
type: Boolean, type: Boolean,
default: () => false, default: () => false,
@@ -30,6 +34,7 @@ export default {
emit('setReplyMode', mode); emit('setReplyMode', mode);
}; };
const handleReplyClick = () => { const handleReplyClick = () => {
if (props.isReplyRestricted) return;
setReplyMode(REPLY_EDITOR_MODES.REPLY); setReplyMode(REPLY_EDITOR_MODES.REPLY);
}; };
const handleNoteClick = () => { const handleNoteClick = () => {
@@ -88,6 +93,7 @@ export default {
<div class="flex justify-between h-[3.25rem] gap-2 ltr:pl-3 rtl:pr-3"> <div class="flex justify-between h-[3.25rem] gap-2 ltr:pl-3 rtl:pr-3">
<EditorModeToggle <EditorModeToggle
:mode="mode" :mode="mode"
:disabled="isReplyRestricted"
class="mt-3" class="mt-3"
@toggle-mode="handleModeToggle" @toggle-mode="handleModeToggle"
/> />

View File

@@ -170,6 +170,9 @@ export default {
} }
return true; return true;
}, },
isReplyRestricted() {
return !this.currentChat?.can_reply && !this.isAWhatsAppChannel;
},
inboxId() { inboxId() {
return this.currentChat.inbox_id; return this.currentChat.inbox_id;
}, },
@@ -1070,6 +1073,7 @@ export default {
<div ref="replyEditor" class="reply-box" :class="replyBoxClass"> <div ref="replyEditor" class="reply-box" :class="replyBoxClass">
<ReplyTopPanel <ReplyTopPanel
:mode="replyType" :mode="replyType"
:is-reply-restricted="isReplyRestricted"
:is-message-length-reaching-threshold="isMessageLengthReachingThreshold" :is-message-length-reaching-threshold="isMessageLengthReachingThreshold"
:characters-remaining="charactersRemaining" :characters-remaining="charactersRemaining"
:popout-reply-box="popOutReplyBox" :popout-reply-box="popOutReplyBox"
@@ -1180,7 +1184,7 @@ export default {
:is-on-private-note="isOnPrivateNote" :is-on-private-note="isOnPrivateNote"
:is-recording-audio="isRecordingAudio" :is-recording-audio="isRecordingAudio"
:is-send-disabled="isReplyButtonDisabled" :is-send-disabled="isReplyButtonDisabled"
:mode="replyType" :is-note="isPrivate"
:on-file-upload="onFileUpload" :on-file-upload="onFileUpload"
:on-send="onSendReply" :on-send="onSendReply"
:conversation-type="conversationType" :conversation-type="conversationType"