Skip to content

Commit ecea950

Browse files
fixed listview item's loses context on changing position
1 parent df479c6 commit ecea950

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

client/packages/lowcoder/src/comps/generators/withMultiContext.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,11 @@ export function withMultiContext<TCtor extends MultiCompConstructor>(VariantComp
125125
const params = this.cacheParamsMap.get(key);
126126
if (_.isNil(comp) && !_.isNil(params)) {
127127
const mapComps = this.getMap();
128-
if (mapComps.hasOwnProperty(key) && !paramsEqual(params, mapComps[key].getParams())) {
128+
if (
129+
Object.keys(mapComps).length === Object.keys(this.cacheParamsMap.getMap()).length
130+
&& mapComps.hasOwnProperty(key)
131+
&& !paramsEqual(params, mapComps[key].getParams())
132+
) {
129133
// refresh the item, since params changed
130134
// this.dispatch(deferAction(wrapChildAction(MAP_KEY, MapCtor.batchDeleteAction([key]))));
131135
this.dispatch(wrapChildAction(MAP_KEY, MapCtor.batchDeleteAction([key])));
@@ -177,16 +181,18 @@ export function withMultiContext<TCtor extends MultiCompConstructor>(VariantComp
177181
const params = comp.cacheParamsMap.get(key);
178182
if (params) {
179183
const childComp = comp
180-
.getComp(key)!
184+
.getOriginalComp()
181185
.setParams(params)
182186
.changeDispatch(wrapDispatch(wrapDispatch(comp.dispatch, MAP_KEY), key));
183187
const newChildComp = childComp.reduce(childAction);
184188

185-
const comps = { [key]: newChildComp };
186-
comp = comp.setChild(
187-
MAP_KEY,
188-
comp.children[MAP_KEY].reduce(MapCtor.batchSetCompAction(comps))
189-
);
189+
if (childComp !== newChildComp) {
190+
const comps = { [key]: newChildComp };
191+
comp = comp.setChild(
192+
MAP_KEY,
193+
comp.children[MAP_KEY].reduce(MapCtor.batchSetCompAction(comps))
194+
);
195+
}
190196
}
191197
} else {
192198
comp = super.reduce(action);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy