Browse Source

:recycle:

Vanessa 1 year ago
parent
commit
2e850de49e
2 changed files with 2 additions and 18 deletions
  1. 1 9
      app/src/protyle/render/av/asset.ts
  2. 1 9
      app/src/protyle/render/av/select.ts

+ 1 - 9
app/src/protyle/render/av/asset.ts

@@ -108,15 +108,7 @@ export const updateAssetCell = (options: {
         if (!options.blockElement.contains(item)) {
             const rowElement = hasClosestByClassName(item, "av__row");
             if (rowElement) {
-                let cellIndex: number;
-                rowElement.querySelectorAll(".av__cell").forEach((cellElement: HTMLElement, ghostIndex) => {
-                    if (cellElement.dataset.id === item.dataset.id) {
-                        cellIndex = ghostIndex
-                    }
-                });
-                if (typeof cellIndex === "number") {
-                    item = options.cellElements[elementIndex] = options.blockElement.querySelectorAll(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell`)[cellIndex] as HTMLElement;
-                }
+                item = options.cellElements[elementIndex] = options.blockElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${item.dataset.colId}"]`) as HTMLElement
             }
         }
         const cellValue = genCellValueByElement(getTypeByCellElement(item) || item.dataset.type as TAVCol, item);

+ 1 - 9
app/src/protyle/render/av/select.ts

@@ -432,15 +432,7 @@ export const addColOptionOrCell = (protyle: IProtyle, data: IAV, cellElements: H
         cellElements.forEach((item, index) => {
             const rowElement = hasClosestByClassName(item, "av__row");
             if (rowElement) {
-                let cellIndex: number;
-                rowElement.querySelectorAll(".av__cell").forEach((cellElement: HTMLElement, ghostIndex) => {
-                    if (cellElement.dataset.id === item.dataset.id) {
-                        cellIndex = ghostIndex
-                    }
-                });
-                if (typeof cellIndex === "number") {
-                    cellElements[index] = blockElement.querySelectorAll(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell`)[cellIndex] as HTMLElement;
-                }
+                cellElements[index] = blockElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${item.dataset.colId}"]`) as HTMLElement;
             }
         });
     }