We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 555338b commit 8b95960Copy full SHA for 8b95960
packages/core/reducer/reduce.ts
@@ -115,13 +115,18 @@ export const replaceAction = <UserData extends Data>(
115
return walkTree<UserData>(
116
state,
117
(content) => content,
118
- (childItem) => {
+ (childItem, path) => {
119
+ const pathIds = path.map((p) => p.split(":")[0]);
120
+
121
if (childItem.props.id === action.data.props.id) {
122
return action.data;
123
} else if (childItem.props.id === parentId) {
124
return childItem;
125
} else if (idsInPath.indexOf(childItem.props.id) > -1) {
- // This node is in the path of the target node
126
+ // Node is parent of target
127
+ return childItem;
128
+ } else if (pathIds.indexOf(action.data.props.id) > -1) {
129
+ // Node is child target
130
131
}
132
0 commit comments