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

为 NTree 追加访问 pendingNodeKey 属性或添加关闭键盘操作的选项 #3438

Closed
qingruikz opened this issue Aug 7, 2022 · 0 comments · Fixed by #3440
Closed

为 NTree 追加访问 pendingNodeKey 属性或添加关闭键盘操作的选项 #3438

qingruikz opened this issue Aug 7, 2022 · 0 comments · Fixed by #3440
Labels
feature request New feature or request

Comments

@qingruikz
Copy link

qingruikz commented Aug 7, 2022

This function solves the problem (这个功能解决的问题)

正常情况:

  • 在非受控模式下使用 NTree 时,使用箭头按键可以正常显示并改变 pendingNode(浅色的候选节点),而按 Enter 可以把候选节点变为实际选中的节点(依靠 src/tree/src/keyboard.tsx 中的 useKeyboard 函数实现的功能)。

有问题的情况:

  • 但是!如果在受控模式下为 NTree 绑定 selected-keys 的话,使用 Enter 键把候选节点变为实际选中节点的功能将失效(src/tree/src/Tree.tsx 中的 handleSelect 函数不起作用)。
  • 此时,即使退一步,自己来封装箭头按键,也会因为 pendingNodeKeyRef 是靠 provide(treeInjectionKey, {pendingNodeKeyRef}) 注入的,没有在 NTree 的 props 中暴露出来,导致无法从外部访问和修改该属性,使得有些时候候选节点的位置不符合预期。同理,由于没法访问该属性,也无法自己实现上述正常情况下的 Enter 的功能。

Expected API (期望的 API)

不知道这个算不算一个 bug,如果是 bug 的话希望能修一下。如果不是 bug,非受控模式下的这种行为符合预期的话,希望:

  • 可以增加直接访问 pendingNodeKey 的 API
  • 如果不行的话,希望能够增加关闭 NTree 的键盘操作的选项(或者不显示浅色的那个 pendingNode 就好了)
@github-actions github-actions bot added the feature request New feature or request label Aug 7, 2022
07akioni added a commit to 07akioni/naive-ui-fork that referenced this issue Aug 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant