File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed
client/packages/lowcoder/src/comps/comps Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -100,10 +100,14 @@ export class LayoutMenuItemListComp extends list(LayoutMenuItemCompMigrate) {
100
100
const data = this . getView ( ) ;
101
101
this . dispatch (
102
102
this . pushAction (
103
- value || {
104
- label : trans ( "menuItem" ) + " " + ( data . length + 1 ) ,
105
- itemKey : genRandomKey ( ) ,
106
- }
103
+ value
104
+ ? {
105
+ ...value ,
106
+ itemKey : value . itemKey || genRandomKey ( ) ,
107
+ } : {
108
+ label : trans ( "menuItem" ) + " " + ( data . length + 1 ) ,
109
+ itemKey : genRandomKey ( ) ,
110
+ }
107
111
)
108
112
) ;
109
113
}
Original file line number Diff line number Diff line change 1
1
import { useDraggable , useDroppable } from "@dnd-kit/core" ;
2
2
import { trans } from "i18n" ;
3
- import { Fragment } from "react" ;
3
+ import { Fragment , useEffect } from "react" ;
4
4
import styled from "styled-components" ;
5
5
import DroppablePlaceholder from "./DroppablePlaceHolder" ;
6
6
import MenuItem , { ICommonItemProps } from "./MenuItem" ;
7
7
import { IDragData , IDropData } from "./types" ;
8
+ import { LayoutMenuItemComp } from "comps/comps/layout/layoutMenuItemComp" ;
9
+ import { genRandomKey } from "comps/utils/idGenerator" ;
8
10
9
11
const DraggableMenuItemWrapper = styled . div `
10
12
position: relative;
@@ -63,6 +65,22 @@ export default function DraggableMenuItem(props: IDraggableMenuItemProps) {
63
65
disabled : isDragging || disabled || disableDropIn ,
64
66
data : dropData ,
65
67
} ) ;
68
+
69
+ // TODO: Remove this later.
70
+ // Set ItemKey for previously added sub-menus
71
+ useEffect ( ( ) => {
72
+ if ( ! items . length ) return ;
73
+ if ( ! ( items [ 0 ] instanceof LayoutMenuItemComp ) ) return ;
74
+
75
+ return items . forEach ( item => {
76
+ const subItem = item as LayoutMenuItemComp ;
77
+ const itemKey = subItem . children . itemKey . getView ( ) ;
78
+ if ( itemKey === '' ) {
79
+ subItem . children . itemKey . dispatchChangeValueAction ( genRandomKey ( ) )
80
+ }
81
+ } )
82
+ } , [ items ] )
83
+
66
84
return (
67
85
< >
68
86
< DraggableMenuItemWrapper >
You can’t perform that action at this time.
0 commit comments