Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7c55830

Browse files
Merge pull request #2006 from iamfaran/fix/event-context
[Fix]: #1970, #1984 event handler context
2 parents ae2422c + 3ff5663 commit 7c55830

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)

AltStyle によって変換されたページ (->オリジナル) /