@@ -7,11 +7,13 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
77import { IAINoContentFallback } from 'common/components/IAIImageFallback' ;
88import ScrollableContent from 'common/components/OverlayScrollbars/ScrollableContent' ;
99import { colorTokenToCssVar } from 'common/util/colorTokenToCssVar' ;
10+ import { deepClone } from 'common/util/deepClone' ;
1011import { singleWorkflowFieldDndSource } from 'features/dnd/dnd' ;
1112import { triggerPostMoveFlash } from 'features/dnd/util' ;
1213import LinearViewFieldInternal from 'features/nodes/components/flow/nodes/Invocation/fields/LinearViewField' ;
1314import { selectWorkflowSlice , workflowExposedFieldsReordered } from 'features/nodes/store/workflowSlice' ;
1415import type { FieldIdentifier } from 'features/nodes/types/field' ;
16+ import { isEqual } from 'lodash-es' ;
1517import { memo , useEffect } from 'react' ;
1618import { flushSync } from 'react-dom' ;
1719import { useTranslation } from 'react-i18next' ;
@@ -78,11 +80,13 @@ const FieldListInnerContent = memo(({ fields }: { fields: FieldIdentifier[] }) =
7880 return ;
7981 }
8082
81- const indexOfSource = fields . findIndex (
82- ( fieldIdentifier ) => fieldIdentifier . fieldName === sourceData . payload . fieldIdentifier . fieldName
83+ const fieldsClone = deepClone ( fields ) ;
84+
85+ const indexOfSource = fieldsClone . findIndex ( ( fieldIdentifier ) =>
86+ isEqual ( fieldIdentifier , sourceData . payload . fieldIdentifier )
8387 ) ;
84- const indexOfTarget = fields . findIndex (
85- ( fieldIdentifier ) => fieldIdentifier . fieldName === targetData . payload . fieldIdentifier . fieldName
88+ const indexOfTarget = fieldsClone . findIndex ( ( fieldIdentifier ) =>
89+ isEqual ( fieldIdentifier , targetData . payload . fieldIdentifier )
8690 ) ;
8791
8892 if ( indexOfTarget < 0 || indexOfSource < 0 ) {
@@ -113,7 +117,7 @@ const FieldListInnerContent = memo(({ fields }: { fields: FieldIdentifier[] }) =
113117 }
114118
115119 const reorderedFields = reorderWithEdge ( {
116- list : fields ,
120+ list : fieldsClone ,
117121 startIndex : indexOfSource ,
118122 indexOfTarget,
119123 closestEdgeOfTarget,
@@ -126,7 +130,9 @@ const FieldListInnerContent = memo(({ fields }: { fields: FieldIdentifier[] }) =
126130 } ) ;
127131
128132 // Flash the element that was moved
129- const element = document . querySelector ( `[data-field-name="${ sourceData . payload . fieldIdentifier . fieldName } "]` ) ;
133+ const element = document . querySelector (
134+ `[data-field-name="${ sourceData . payload . fieldIdentifier . nodeId } -${ sourceData . payload . fieldIdentifier . fieldName } "]`
135+ ) ;
130136 if ( element instanceof HTMLElement ) {
131137 triggerPostMoveFlash ( element , colorTokenToCssVar ( 'base.700' ) ) ;
132138 }
0 commit comments