diff --git a/frontend/src/App/App.jsx b/frontend/src/App/App.jsx index a6759adab5..85f1db418d 100644 --- a/frontend/src/App/App.jsx +++ b/frontend/src/App/App.jsx @@ -122,7 +122,7 @@ class AppComponent extends React.Component { diff --git a/frontend/src/Editor/Components/Kanban/KanbanBoard.jsx b/frontend/src/Editor/Components/Kanban/KanbanBoard.jsx index ccd9669140..885a9964b3 100644 --- a/frontend/src/Editor/Components/Kanban/KanbanBoard.jsx +++ b/frontend/src/Editor/Components/Kanban/KanbanBoard.jsx @@ -86,7 +86,7 @@ export function KanbanBoard({ widgetHeight, kanbanProps, parentRef }) { }, [shouldUpdateData.current, JSON.stringify(cardDataAsObj)]); useEffect(() => { - droppableItemsColumnId.current = containers.find((container) => items[container].length > 0); + droppableItemsColumnId.current = containers.find((container) => items[container]?.length > 0); }, [items, containers]); registerAction( diff --git a/frontend/src/Editor/Components/Table/Table.jsx b/frontend/src/Editor/Components/Table/Table.jsx index 9c8d41e062..25d5a9e023 100644 --- a/frontend/src/Editor/Components/Table/Table.jsx +++ b/frontend/src/Editor/Components/Table/Table.jsx @@ -287,7 +287,7 @@ export function Table({ let tableData = [], dynamicColumn = []; - const useDynamicColumn = resolveReferences(component.definition.properties?.useDynamicColumn?.value); + const useDynamicColumn = resolveReferences(component.definition.properties?.useDynamicColumn?.value, currentState); if (currentState) { tableData = resolveReferences(component.definition.properties.data.value, currentState, []); dynamicColumn = useDynamicColumn diff --git a/frontend/src/Editor/DraggableBox.jsx b/frontend/src/Editor/DraggableBox.jsx index 5aad5d8643..f5f58b02b8 100644 --- a/frontend/src/Editor/DraggableBox.jsx +++ b/frontend/src/Editor/DraggableBox.jsx @@ -211,10 +211,6 @@ export const DraggableBox = function DraggableBox({ }} onMouseLeave={() => onComponentHover?.(false)} style={getStyles(isDragging, isSelectedComponent)} - onClick={(e) => { - e.stopPropagation(); - setSelectedComponent && setSelectedComponent(id); - }} > e.stopPropagation()} + cancel={`div.table-responsive.jet-data-table, div.calendar-widget, div.text-input, .textarea, .map-widget, .range-slider, .kanban-container, div.real-canvas`} onResizeStop={(e, direction, ref, d, position) => { setResizing(false); onResizeStop(id, e, direction, ref, d, position); diff --git a/frontend/src/_helpers/appUtils.js b/frontend/src/_helpers/appUtils.js index a5399938e1..653f286ed0 100644 --- a/frontend/src/_helpers/appUtils.js +++ b/frontend/src/_helpers/appUtils.js @@ -24,6 +24,7 @@ import { v4 as uuidv4 } from 'uuid'; import { allSvgs } from '@tooljet/plugins/client'; import urlJoin from 'url-join'; import { tooljetDbOperations } from '@/Editor/QueryManager/QueryEditors/TooljetDatabase/operations'; +import { flushSync } from 'react-dom'; // TODO: It can be removed once we've a proper state update flow const ERROR_TYPES = Object.freeze({ ReferenceError: 'ReferenceError', @@ -952,48 +953,51 @@ export function runQuery(_ref, queryId, queryName, confirmed = undefined, mode = if (promiseStatus === 'failed' || promiseStatus === 'Bad Request') { const errorData = query.kind === 'runpy' ? data.data : data; - return _self.setState( - { - currentState: { - ..._self.state.currentState, - queries: { - ..._self.state.currentState.queries, - [queryName]: _.assign( - { - ..._self.state.currentState.queries[queryName], - isLoading: false, + flushSync(() => { + return _self.setState( + { + currentState: { + ..._self.state.currentState, + queries: { + ..._self.state.currentState.queries, + [queryName]: _.assign( + { + ..._self.state.currentState.queries[queryName], + isLoading: false, + }, + query.kind === 'restapi' + ? { + request: data.data.requestObject, + response: data.data.responseObject, + responseHeaders: data.data.responseHeaders, + } + : {} + ), + }, + errors: { + ..._self.state.currentState.errors, + [queryName]: { + type: 'query', + kind: query.kind, + data: errorData, + options: options, }, - query.kind === 'restapi' - ? { - request: data.data.requestObject, - response: data.data.responseObject, - responseHeaders: data.data.responseHeaders, - } - : {} - ), - }, - errors: { - ..._self.state.currentState.errors, - [queryName]: { - type: 'query', - kind: query.kind, - data: errorData, - options: options, }, }, }, - }, - () => { - resolve(data); - onEvent(_self, 'onDataQueryFailure', { - definition: { events: dataQuery.options.events }, - }); - if (mode !== 'view') { - const err = query.kind == 'tooljetdb' ? data?.error || data : _.isEmpty(data.data) ? data : data.data; - toast.error(err?.message); + () => { + resolve(data); + onEvent(_self, 'onDataQueryFailure', { + definition: { events: dataQuery.options.events }, + }); + if (mode !== 'view') { + const err = + query.kind == 'tooljetdb' ? data?.error || data : _.isEmpty(data.data) ? data : data.data; + toast.error(err?.message); + } } - } - ); + ); + }); } let rawData = data.data; @@ -1009,35 +1013,36 @@ export function runQuery(_ref, queryId, queryName, confirmed = undefined, mode = 'edit' ); if (finalData.status === 'failed') { - console.log('runPythonTransformation', finalData); - return _self.setState( - { - currentState: { - ..._self.state.currentState, - queries: { - ..._self.state.currentState.queries, - [queryName]: { - ..._self.state.currentState.queries[queryName], - isLoading: false, + flushSync(() => { + return _self.setState( + { + currentState: { + ..._self.state.currentState, + queries: { + ..._self.state.currentState.queries, + [queryName]: { + ..._self.state.currentState.queries[queryName], + isLoading: false, + }, }, - }, - errors: { - ..._self.state.currentState.errors, - [queryName]: { - type: 'transformations', - data: finalData, - options: options, + errors: { + ..._self.state.currentState.errors, + [queryName]: { + type: 'transformations', + data: finalData, + options: options, + }, }, }, }, - }, - () => { - resolve(finalData); - onEvent(_self, 'onDataQueryFailure', { - definition: { events: dataQuery.options.events }, - }); - } - ); + () => { + resolve(finalData); + onEvent(_self, 'onDataQueryFailure', { + definition: { events: dataQuery.options.events }, + }); + } + ); + }); } } @@ -1047,61 +1052,64 @@ export function runQuery(_ref, queryId, queryName, confirmed = undefined, mode = duration: notificationDuration, }); } - - _self.setState( - { - currentState: { - ..._self.state.currentState, - queries: { - ..._self.state.currentState.queries, - [queryName]: _.assign( - { - ..._self.state.currentState.queries[queryName], - isLoading: false, - data: finalData, - rawData, - }, - query.kind === 'restapi' - ? { - request: data.request, - response: data.response, - responseHeaders: data.responseHeaders, - } - : {} - ), - }, - }, - }, - () => { - resolve({ status: 'ok', data: finalData }); - onEvent(_self, 'onDataQuerySuccess', { definition: { events: dataQuery.options.events } }, mode); - - if (mode !== 'view') { - toast(`Query (${queryName}) completed.`, { - icon: '🚀', - }); - } - } - ); - }) - .catch(({ error }) => { - if (mode !== 'view') toast.error(error ?? 'Unknown error'); - _self.setState( - { - currentState: { - ..._self.state.currentState, - queries: { - ..._self.state.currentState.queries, - [queryName]: { - isLoading: false, + flushSync(() => { + _self.setState( + { + currentState: { + ..._self.state.currentState, + queries: { + ..._self.state.currentState.queries, + [queryName]: _.assign( + { + ..._self.state.currentState.queries[queryName], + isLoading: false, + data: finalData, + rawData, + }, + query.kind === 'restapi' + ? { + request: data.request, + response: data.response, + responseHeaders: data.responseHeaders, + } + : {} + ), }, }, }, - }, - () => { - resolve({ status: 'failed', message: error }); - } - ); + () => { + resolve({ status: 'ok', data: finalData }); + onEvent(_self, 'onDataQuerySuccess', { definition: { events: dataQuery.options.events } }, mode); + + if (mode !== 'view') { + toast(`Query (${queryName}) completed.`, { + icon: '🚀', + }); + } + } + ); + }); + }) + .catch(({ error }) => { + if (mode !== 'view') toast.error(error ?? 'Unknown error'); + flushSync(() => { + _self.setState( + { + currentState: { + ..._self.state.currentState, + queries: { + ..._self.state.currentState.queries, + [queryName]: { + isLoading: false, + }, + }, + }, + }, + () => { + resolve({ status: 'failed', message: error }); + } + ); + }); }); }); });