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) {
100100 const data = this . getView ( ) ;
101101 this . dispatch (
102102 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+ }
107111 )
108112 ) ;
109113 }
Original file line number Diff line number Diff line change 11import { useDraggable , useDroppable } from "@dnd-kit/core" ;
22import { trans } from "i18n" ;
3- import { Fragment } from "react" ;
3+ import { Fragment , useEffect } from "react" ;
44import styled from "styled-components" ;
55import DroppablePlaceholder from "./DroppablePlaceHolder" ;
66import MenuItem , { ICommonItemProps } from "./MenuItem" ;
77import { IDragData , IDropData } from "./types" ;
8+ import { LayoutMenuItemComp } from "comps/comps/layout/layoutMenuItemComp" ;
9+ import { genRandomKey } from "comps/utils/idGenerator" ;
810
911const DraggableMenuItemWrapper = styled . div `
1012 position: relative;
@@ -63,6 +65,22 @@ export default function DraggableMenuItem(props: IDraggableMenuItemProps) {
6365 disabled : isDragging || disabled || disableDropIn ,
6466 data : dropData ,
6567 } ) ;
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+
6684 return (
6785 < >
6886 < DraggableMenuItemWrapper >
You can’t perform that action at this time.
0 commit comments