VisActor / VisActor/VTable

[Bug] 使用vue-render方式渲染时,再进行路由跳转回来会发生重叠

Open
#4,444 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
3.7k
Forks
486
Avg merge
1d 19h
Merged PRs (30d)
16

Description

Version

1.19.8

Link to Minimal Reproduction

null

Steps to Reproduce

当CustomLayout使用vue-render方式渲染时,再进行路由跳转回来会发生重叠

Current Behavior
if (slots[field]) {
  column.customLayout = (args) => {
    const { table, row, col, rect, value } = args
    const { height, width } = rect ?? table.getCellRect(col, row)
    const record = table.getRecordByCell(col, row)
    const curColumn = tableInstance.value.getBodyColumnDefine(col, row)
    const parentRecord = record.$level > 1 ? tableInstance.value.getRecordByCell(col, row - record.$index) : undefined
    const container = new VTable.CustomLayout.Group({
      height,
      width,
      display: 'flex',
      alignItems: 'center',
      vue: {
        element: h(
          'div',
          {
            class: 'text-12 text-#333 flex flex-nowrap whitespace-nowrap items-center',
          },
          slots[field]({ record, column: curColumn, value, parentRecord }),
        ),
        container: table.bodyDomContainer,
      },
    } as any)

    return {
      rootContainer: container,
      renderDefault: false,
    }
  }
}

Image

目前通过特殊方式解决 😭每次跳回来就干掉所有原来的div

onActivated(() => {
  // 兼容路由跳转回来会保留原来vue-render的元素
  if (listTableRef.value.querySelector('canvas')) {
    for (const element of listTableRef.value.querySelectorAll('[data-vue-renderid]')) {
      element.remove()
    }
  }
})
Expected Behavior

不会发生重叠

Environment
- OS:
- Browser:
- Framework:
Any additional comments?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CustomLayout.Group vue-render path shown in the issue, especially its element and table.bodyDomContainer settings, then trace what happens when the route is left and revisited. Reproduce the route round trip using the supplied snippet and inspect the data-vue-renderid elements. Done means returning to the route no longer leaves overlapping elements, without relying on the onActivated cleanup workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.