amis icon indicating copy to clipboard operation
amis copied to clipboard

Tree控件勾选判断条件的bug,当children=[]时逻辑有误勾选不上

Open hiro0729 opened this issue 5 years ago • 3 comments

https://github.com/baidu/amis/blob/e34df2c938f218569d7720c75b60015ff71902ff/src/components/Tree.tsx#L293

此处判断有问题,child.children&&child.children.length

hiro0729 avatar Aug 05 '21 06:08 hiro0729

具体场景可以描述一下么,请附上配置schema和复现步骤

RickCole21 avatar Aug 26 '21 09:08 RickCole21

看我截图,就是当后台返回children=[]时,判断分支走不进去,勾不上 image

hiro0729 avatar Aug 26 '21 09:08 hiro0729

{
  "type": "page",
  "body": {
    "type": "form",
    "debug": true,
    "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
    "body": [
      {
        "type": "input-tree",
        "name": "tree1",
        "label": "只包含子节点的值",
        "multiple": true,
        "onlyChildren": true,
        "options": [
          {
            "label": "A",
            "value": "a",
            "children": []
          },
          {
            "label": "B",
            "value": "b",
            "children": [
              {
                "label": "B-1",
                "value": "b-1",
                "children": []
              },
              {
                "label": "B-2",
                "value": "b-2",
                "children": []
              },
              {
                "label": "B-3",
                "value": "b-3",
                "children": []
              }
            ]
          },
          {
            "label": "C",
            "value": "c",
            "children": []
          }
        ]
      }
    ]
  }
}

image

就是叶节点 "children": [] 的情况下,勾父节点那段代码判断有问题,无法勾中,正好我碰到服务端接口没数据返回的不是null。。。

hiro0729 avatar Aug 26 '21 09:08 hiro0729