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

fix: update foldertree new folder #247

Merged
merged 1 commit into from
Jul 15, 2021
Merged

fix: update foldertree new folder #247

merged 1 commit into from
Jul 15, 2021

Conversation

mortalYoung
Copy link
Collaborator

简介

  • 修复 folderTree 修改名称的时候,如果没有名称会直接删除节点的问题
  • 修复 folderTree 在收起状态的文件夹下新增节点的时候,该文件夹不会展开的问题
  • 修复 folderTree 修改名称之后,tab 没有同步更新的问题

主要变更

  • 在 rename 触发事件中增加判断逻辑,如果没有不存在 name ,不可以直接删除节点,需要先去拿到当前节点在 tree 中的状态。如果状态存在且有 name 则表示是编辑,那就取消编辑状态就可以了,否则再删除节点
  • 在 rename 触发事件的结尾,判断当前修改的节点是否存在于 tab 中,如果是则去修改 tab 内容
  • 优化 updateTab 函数,由于同一个文件可能会在多个 group 中打开,所以需要去遍历全部的 group 做修改。同时,修改内容不应该理论上只修改 group.data,但是实际上应该修改 group.tab current.tab group.data 至少三处,来确保数据的一致性
  • addNode 赋值 state 的时候,通过深拷贝可以触发 data 的引用地址不同,从而触发 view 的 useLayoutEffect,然后借助一个 stack 来层次遍历 data,并记录遍历的 path,对 path 上的每一个文件夹都做 expand 操作

Related Issues

Closed #244

@mumiao mumiao self-requested a review July 15, 2021 08:03
@mumiao mumiao added bug Something isn't working enhancement New feature or request labels Jul 15, 2021
@mumiao mumiao merged commit c505abe into main Jul 15, 2021
@mumiao mumiao deleted the fix/folderTree branch July 15, 2021 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

collection explore folderTree bugFIxes
2 participants