@dataloop-ai/components 0.20.167 → 0.20.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.20.167",
3
+ "version": "0.20.168",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -788,8 +788,12 @@ export default defineComponent({
788
788
  let shouldSkipValidation = false
789
789
 
790
790
  if (storedValidTarget.value && targetRow.value) {
791
- const targetParent = findParentForChild(targetRow.value.id, tableRows.value)
792
- if (targetParent === storedValidTarget.value.id) {
791
+ const isStoredTargetAncestor = isAncestor(
792
+ storedValidTarget.value.id,
793
+ targetRow.value.id,
794
+ tableRows.value
795
+ )
796
+ if (isStoredTargetAncestor) {
793
797
  finalTarget = storedValidTarget.value
794
798
  shouldSkipValidation = true
795
799
  }
@@ -920,7 +924,6 @@ export default defineComponent({
920
924
  return false
921
925
  }
922
926
 
923
-
924
927
  if (targetRow.disableDraggable) {
925
928
  return false
926
929
  }
@@ -1025,6 +1028,22 @@ export default defineComponent({
1025
1028
  return parentMap.get(childId) || null
1026
1029
  }
1027
1030
 
1031
+ const isAncestor = (
1032
+ ancestorId: string,
1033
+ childId: string,
1034
+ rows: DlTableRow[]
1035
+ ): boolean => {
1036
+ const parentMap = buildParentMap(rows)
1037
+ while (parentMap.has(childId)) {
1038
+ const parentId = parentMap.get(childId)!
1039
+ if (parentId === ancestorId) {
1040
+ return true
1041
+ }
1042
+ childId = parentId
1043
+ }
1044
+ return false
1045
+ }
1046
+
1028
1047
  const calculateRowLevel = (row: DlTableRow): number => {
1029
1048
  const parentMap = buildParentMap(props.rows)
1030
1049
  let level = 1