fix: Prioritize SDK enableFileUpload flag when explicitly set (#13091)
### Problem Currently, the attachment button visibility in the widget uses both the SDK's `enableFileUpload` flag AND the inbox's attachment settings with an AND condition. This creates an issue for users who want to control attachments solely through inbox settings, since the SDK flag defaults to `true` even when not explicitly provided. **Before:** - SDK not set → `enableFileUpload: true` (default) + inbox setting = attachment shown only if both true - SDK set to false → `enableFileUpload: false` + inbox setting = attachment always hidden - SDK set to true → `enableFileUpload: true` + inbox setting = attachment shown only if both true This meant users couldn't rely solely on inbox settings when the SDK flag wasn't explicitly provided. ### Solution Changed the logic to prioritize explicit SDK configuration when provided, and fall back to inbox settings when not provided: **After:** - SDK not set → `enableFileUpload: undefined` → use inbox setting only - SDK set to false → `enableFileUpload: false` → hide attachment (SDK controls) - SDK set to true → `enableFileUpload: true` → show attachment (SDK controls) --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import { DirectUpload } from 'activestorage';
|
||||
import { mapGetters } from 'vuex';
|
||||
import { emitter } from 'shared/helpers/mitt';
|
||||
import { useAttachments } from '../composables/useAttachments';
|
||||
|
||||
export default {
|
||||
components: { FluentIcon, FileUpload, Spinner },
|
||||
@@ -20,13 +21,16 @@ export default {
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const { canHandleAttachments } = useAttachments();
|
||||
return { canHandleAttachments };
|
||||
},
|
||||
data() {
|
||||
return { isUploading: false };
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
globalConfig: 'globalConfig/get',
|
||||
shouldShowFilePicker: 'appConfig/getShouldShowFilePicker',
|
||||
}),
|
||||
fileUploadSizeLimit() {
|
||||
return resolveMaximumFileUploadSize(
|
||||
@@ -46,7 +50,7 @@ export default {
|
||||
methods: {
|
||||
handleClipboardPaste(e) {
|
||||
// If file picker is not enabled, do not allow paste
|
||||
if (!this.shouldShowFilePicker) return;
|
||||
if (!this.canHandleAttachments) return;
|
||||
|
||||
const items = (e.clipboardData || e.originalEvent.clipboardData).items;
|
||||
// items is a DataTransferItemList object which does not have forEach method
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mapGetters } from 'vuex';
|
||||
|
||||
import ChatAttachmentButton from 'widget/components/ChatAttachment.vue';
|
||||
import ChatSendButton from 'widget/components/ChatSendButton.vue';
|
||||
import configMixin from '../mixins/configMixin';
|
||||
import { useAttachments } from '../composables/useAttachments';
|
||||
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
|
||||
import ResizableTextArea from 'shared/components/ResizableTextArea.vue';
|
||||
|
||||
@@ -18,7 +18,6 @@ export default {
|
||||
FluentIcon,
|
||||
ResizableTextArea,
|
||||
},
|
||||
mixins: [configMixin],
|
||||
props: {
|
||||
onSendMessage: {
|
||||
type: Function,
|
||||
@@ -29,6 +28,18 @@ export default {
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const {
|
||||
canHandleAttachments,
|
||||
shouldShowEmojiPicker,
|
||||
hasEmojiPickerEnabled,
|
||||
} = useAttachments();
|
||||
return {
|
||||
canHandleAttachments,
|
||||
shouldShowEmojiPicker,
|
||||
hasEmojiPickerEnabled,
|
||||
};
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userInput: '',
|
||||
@@ -41,15 +52,10 @@ export default {
|
||||
...mapGetters({
|
||||
widgetColor: 'appConfig/getWidgetColor',
|
||||
isWidgetOpen: 'appConfig/getIsWidgetOpen',
|
||||
shouldShowFilePicker: 'appConfig/getShouldShowFilePicker',
|
||||
shouldShowEmojiPicker: 'appConfig/getShouldShowEmojiPicker',
|
||||
}),
|
||||
showAttachment() {
|
||||
return (
|
||||
this.shouldShowFilePicker &&
|
||||
this.hasAttachmentsEnabled &&
|
||||
this.userInput.length === 0
|
||||
);
|
||||
return this.canHandleAttachments && this.userInput.length === 0;
|
||||
},
|
||||
showSendButton() {
|
||||
return this.userInput.length > 0;
|
||||
|
||||
Reference in New Issue
Block a user