Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于executeSetControlValue设置为空字符串报错问题 #439

Closed
biubiubiu-max opened this issue Feb 29, 2024 · 3 comments
Closed

关于executeSetControlValue设置为空字符串报错问题 #439

biubiubiu-max opened this issue Feb 29, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@biubiubiu-max
Copy link

version

0.9.66

Link to minimal reproduction

No response

Steps to reproduce

window.editor.command.executeSetControlValue({
conceptId: '1',
value: ''
})

What is expected?

当设置为空串应当展示placeholder

What is actually happening?

执行clearValue中的const value = this.getValue() 这段,getValue报错,大概是在this.control.getRange()找节点的时候报错

System Info

No response

Any additional comments?

No response

@Hufe921
Copy link
Owner

Hufe921 commented Feb 29, 2024

没有复现,提供一下操作步骤及编辑器data

@biubiubiu-max
Copy link
Author

biubiubiu-max commented Mar 1, 2024

如此复现:
image
我下载github上的v0.9.66本地是有这个问题的,
经调试:这部分代码 getValue()

const elementList = this.control.getElementList()
    const { startIndex } = this.control.getRange()
    const startElement = elementList[startIndex]
    const data: IElement[] = []
    // 向左查找
    let preIndex = startIndex
    while (preIndex > 0) {
      const preElement = elementList[preIndex]
      if (
        preElement.controlId !== startElement.controlId ||
        preElement.controlComponent === ControlComponent.PREFIX
      ) {
        break
      }
      if (preElement.controlComponent === ControlComponent.VALUE) {
        data.unshift(preElement)
      }
      preIndex--
    }

startElement是没找到的,getRange()边界似乎没有更新

@Hufe921 Hufe921 added the bug Something isn't working label Mar 1, 2024
baseWalker added a commit to baseWalker/canvas-editor that referenced this issue Mar 1, 2024
@biubiubiu-max
Copy link
Author

似乎可行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants