Skip to content

Commit 3ff5663

Browse files
committed
[Fix]: #1970, #1984 event handler context
1 parent 428b59a commit 3ff5663

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

client/packages/lowcoder/src/comps/controls/actionSelector/actionSelectorControl.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,10 @@ function actionSelectorControl(needContext: boolean) {
249249
const condition = this.children.condition.getView();
250250
const ignored = getReduceContext().disableUpdateState || (isConditionSet && !condition);
251251
const ignorePromise = Promise.resolve();
252-
const realNeedContext = needContext || getReduceContext().inEventContext;
253252
const actionPromise = () => {
254-
// return realNeedContext ? action.value.func() : this.children.comp.getView()();
255-
// commenting because it's using old context for event handlers inside list/grid
256-
return this.children.comp.getView()();
253+
return action.value.context && action.value.func
254+
? action.value.func()
255+
: this.children.comp.getView()();
257256
};
258257
handlePromiseAfterResult(action, ignored ? ignorePromise : actionPromise());
259258
return this;

client/packages/lowcoder/src/comps/controls/optionsControl.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { JSONObject, JSONValue } from "util/jsonTypes";
3838
import { ButtonEventHandlerControl } from "./eventHandlerControl";
3939
import { ControlItemCompBuilder } from "comps/generators/controlCompBuilder";
4040
import { ColorControl } from "./colorControl";
41-
import { reduceInContext } from "../utils/reduceContext";
41+
4242
import { BorderOuterOutlined } from "@ant-design/icons";
4343

4444
// Tag preset color options
@@ -334,14 +334,6 @@ export function mapOptionsControl<T extends OptionsControlType>(
334334
}
335335

336336
override reduce(action: CompAction) {
337-
// TODO: temporary solution condition to fix context issue in dropdown option's events
338-
if (
339-
action.type === CompActionTypes.CUSTOM
340-
&& (action.value as JSONObject).type === 'actionTriggered'
341-
) {
342-
const comp = reduceInContext({ inEventContext: true }, () => super.reduce(action));
343-
return comp;
344-
} else
345337
if (action.type === CompActionTypes.UPDATE_NODES_V2) {
346338
const comp = super.reduce(action)
347339
if (comp.children.data !== this.children.data) {

0 commit comments

Comments
 (0)