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

[Tree] label 属性的 setData 无法触发更新 #2609

Closed
NWYLZW opened this issue Nov 22, 2023 · 5 comments
Closed

[Tree] label 属性的 setData 无法触发更新 #2609

NWYLZW opened this issue Nov 22, 2023 · 5 comments
Assignees
Labels
🐞 bug Something isn't working compatibility issue for compatibility to be published fixed, not be published

Comments

@NWYLZW
Copy link
Collaborator

NWYLZW commented Nov 22, 2023

tdesign-react 版本

1.3.1

重现链接

https://codesandbox.io/p/sandbox/tdesign-react-demo-forked-kxz6yc?file=%2Fsrc%2Fdemo.jsx%3A64%2C52

重现步骤

  • 双击结点 label ,聚焦至输入框
  • 进行输入,测试 esc, enter 是否能触发
  • 点击其他空白处触发 blur
image

667e460d81e532bf72f74be4d6b2e4ee

期望结果

setData 设置 isEditing: false 能正常触发渲染并更新数据

实际结果

blur 存在可能触发更新视图,而按键事件均不可触发更新视图

框架版本

React(18.2.0)

浏览器版本

Any

系统版本

Any

Node版本

Any

补充说明

No response

Copy link
Contributor

👋 @NWYLZW,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

Copy link
Contributor

github-actions bot commented Nov 22, 2023

♥️ 有劳 @shryzhang @lysongzi @Ruoleery @uyarn 尽快确认问题。
确认有效后将下一步计划和可能需要的时间回复给 @NWYLZW

@HaixingOoO HaixingOoO added the 🐞 bug Something isn't working label Nov 23, 2023
@NWYLZW NWYLZW changed the title [Tree] label 属性的 setData 不一定能触发更新 [Tree] label 属性的 setData 无法触发更新 Nov 23, 2023
@NWYLZW
Copy link
Collaborator Author

NWYLZW commented Nov 23, 2023

当我尝试在 tdesign-react 项目启动的 start 指令中的开发服务上复现时,这居然是无法触发的。

Export-1700727843943

文件路径在:src/tree/_example/base.jsx
修改内容:

export default () => <Tree
  data={items}
  activable
  hover
  transition
  label={(node) => node.data.isEditing
    ? <input
      defaultValue={node.data.label}
      onBlur={e => node.setData({ ...node.data, label: e.target.value, isEditing: false })}
      onClick={e => e.stopPropagation()}
    />
    : <span onDoubleClick={e => {
      e.stopPropagation();
      node.setData({ ...node.data, isEditing: true });
    }}>
      {node.data.label}
    </span>}
/>;

@NWYLZW
Copy link
Collaborator Author

NWYLZW commented Nov 23, 2023

经过讨论,可能是由于 common submodule 没有更新导致的 tree node class 的数据响应式关系并未关联上导致的 setData 无法触发数据更新。

@HaixingOoO HaixingOoO added the compatibility issue for compatibility label Nov 23, 2023
@uyarn uyarn added the in progress in progress label Nov 30, 2023
@HaixingOoO HaixingOoO added to be published fixed, not be published and removed in progress in progress labels Feb 26, 2024
@HaixingOoO
Copy link
Collaborator

fixed 1.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working compatibility issue for compatibility to be published fixed, not be published
Projects
None yet
Development

No branches or pull requests

3 participants