diff --git a/frontend/src/Editor/Components/FilePicker.jsx b/frontend/src/Editor/Components/FilePicker.jsx index 9a4f7464e2..5b01bcea3a 100644 --- a/frontend/src/Editor/Components/FilePicker.jsx +++ b/frontend/src/Editor/Components/FilePicker.jsx @@ -4,6 +4,7 @@ import { resolveWidgetFieldValue } from '@/_helpers/utils'; import { toast } from 'react-hot-toast'; import * as XLSX from 'xlsx/xlsx.mjs'; import { useCurrentState } from '@/_stores/currentStateStore'; +import { useAppInfo } from '@/_stores/appDataStore'; export const FilePicker = ({ id, @@ -54,6 +55,10 @@ export const FilePicker = ({ const parsedWidgetVisibility = typeof widgetVisibility !== 'boolean' ? resolveWidgetFieldValue(widgetVisibility, currentState) : widgetVisibility; + const { events: allAppEvents } = useAppInfo(); + + const filePickerEvents = allAppEvents.filter((event) => event.target === 'component' && event.sourceId === id); + const bgThemeColor = darkMode ? '#232E3C' : '#fff'; const baseStyle = { @@ -235,7 +240,7 @@ export const FilePicker = ({ onComponentOptionChanged(component, 'file', [], id); } - if (acceptedFiles.length !== 0) { + if (acceptedFiles.length !== 0 && onEvent) { const fileData = parsedEnableMultiple ? [...selectedFiles] : []; if (parseContent) { onComponentOptionChanged(component, 'isParsing', true, id); @@ -250,7 +255,8 @@ export const FilePicker = ({ }); setSelectedFiles(fileData); onComponentOptionChanged(component, 'file', fileData, id); - onEvent('onFileSelected', { component }) + + onEvent('onFileSelected', filePickerEvents, { component }) .then(() => { setAccepted(true); // eslint-disable-next-line no-unused-vars @@ -263,7 +269,7 @@ export const FilePicker = ({ }, 600); }); }) - .then(() => onEvent('onFileLoaded', { component })); + .then(() => onEvent('onFileLoaded', filePickerEvents, { component })); } if (fileRejections.length > 0) { @@ -286,7 +292,7 @@ export const FilePicker = ({ copy.splice(index, 1); return copy; }); - onEvent('onFileDeselected', { component }); + onEvent('onFileDeselected', filePickerEvents); }; useEffect(() => { diff --git a/frontend/src/Editor/Viewer.jsx b/frontend/src/Editor/Viewer.jsx index 9580d27c2f..8ccb5e682b 100644 --- a/frontend/src/Editor/Viewer.jsx +++ b/frontend/src/Editor/Viewer.jsx @@ -506,7 +506,7 @@ class ViewerComponent extends React.Component { }; handleEvent = (eventName, events, options) => { - onEvent(this.getViewerRef(), eventName, events, options, 'view'); + return onEvent(this.getViewerRef(), eventName, events, options, 'view'); }; computeCanvasMaxWidth = () => {