Movatterモバイル変換


[0]ホーム

URL:


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

Commit11c6dcd

Browse files
event Handlers in Dropdown do not read current item variable correctly
1 parent4ae9f71 commit11c6dcd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

‎client/packages/lowcoder/src/comps/comps/buttonComp/dropdownComp.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,16 @@ const DropdownTmpComp = (function () {
8383
key:option.label+" - "+index,
8484
disabled:option.disabled,
8585
icon:hasIcon&&<span>{option.prefixIcon}</span>,
86-
onEvent:option.onEvent,
86+
index,
8787
}));
8888

8989
constmenu=(
9090
<Menu
9191
items={items}
92-
onClick={({ key})=>items.find((o)=>o.key===key)?.onEvent("click")}
92+
onClick={({ key})=>{
93+
constitem=items.find((o)=>o.key===key);
94+
item&&props.options[item.index]?.onEvent("click");
95+
}}
9396
/>
9497
);
9598

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ import {
3333
importstyledfrom"styled-components";
3434
import{lastValueIfEqual}from"util/objectUtils";
3535
import{getNextEntityName}from"util/stringUtils";
36-
import{JSONValue}from"util/jsonTypes";
36+
import{JSONObject,JSONValue}from"util/jsonTypes";
3737
import{ButtonEventHandlerControl}from"./eventHandlerControl";
3838
import{ControlItemCompBuilder}from"comps/generators/controlCompBuilder";
3939
import{ColorControl}from"./colorControl";
4040
import{StringStateControl}from"./codeStateControl";
41+
import{reduceInContext}from"../utils/reduceContext";
4142

4243
constOptionTypes=[
4344
{
@@ -312,8 +313,16 @@ export function mapOptionsControl<T extends OptionsControlType>(
312313
}
313314

314315
overridereduce(action:CompAction){
315-
constcomp=super.reduce(action);
316+
// TODO: temporary solution condition to fix context issue in dropdown option's events
317+
if(
318+
action.type===CompActionTypes.CUSTOM
319+
&&(action.valueasJSONObject).type==='actionTriggered'
320+
){
321+
constcomp=reduceInContext({inEventContext:true},()=>super.reduce(action));
322+
returncomp;
323+
}else
316324
if(action.type===CompActionTypes.UPDATE_NODES_V2){
325+
constcomp=super.reduce(action)
317326
if(comp.children.data!==this.children.data){
318327
constsourceArray=comp.children.data.getView();
319328
constdataExample=sourceArray ?sourceArray[0] :undefined;
@@ -323,7 +332,7 @@ export function mapOptionsControl<T extends OptionsControlType>(
323332
}
324333
}
325334
}
326-
returncomp;
335+
returnsuper.reduce(action);
327336
}
328337

329338
updateContext(dataExample:JSONValue){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp