Skip to content

Commit 1740278

Browse files
committed
fix: #1755 nested components inside hook components
1 parent ff79f07 commit 1740278

1 file changed

Lines changed: 5 additions & 10 deletions

File tree

client/packages/lowcoder/src/comps/utils/hookCompOperator.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ import { trans } from "i18n";
88
export class HookCompOperator {
99
private static copyHooks: HookComp[] = [];
1010

11-
/**
12-
* Copy non-singleton hook components by name from selectedCompNames.
13-
*/
1411
static copyComp(editorState: EditorState, compRecords: Record<string, Comp>) {
1512
const selectedNames = Array.from(editorState.selectedCompNames);
1613
if (!selectedNames.length) {
1714
return false;
1815
}
1916

20-
const hookMap = editorState.getHooksComp().getAllCompItems();
21-
const selectedHookComps = Object.values(hookMap)
17+
const hookComps = editorState.getHooksComp().getView();
18+
const selectedHookComps = hookComps
2219
.filter((comp: any) => {
2320
const name = comp.children.name.getView();
2421
const compType = comp.children.compType.getView();
@@ -30,17 +27,15 @@ export class HookCompOperator {
3027
}
3128

3229
this.copyHooks = selectedHookComps;
33-
messageInstance.success(trans("notification.copySuccess"));
30+
messageInstance.success(trans("copySuccess"));
3431
return true;
3532
}
3633

3734
static clearCopy() {
3835
this.copyHooks = [];
3936
}
4037

41-
/**
42-
* Paste previously copied hook components and re-generate nested component names.
43-
*/
38+
4439
static pasteComp(editorState: EditorState) {
4540
if (!this.copyHooks.length) {
4641
messageInstance.info(trans("gridCompOperator.selectCompFirst"));
@@ -86,7 +81,7 @@ export class HookCompOperator {
8681
});
8782

8883
editorState.setSelectedCompNames(newNames, "leftPanel");
89-
messageInstance.success(trans("notification.copySuccess"));
84+
messageInstance.success(trans("copySuccess"));
9085
return true;
9186
}
9287
}

0 commit comments

Comments
 (0)