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

SelectTree 搜索输入框在输入值时候失焦问题 #1491

Closed
chownchen opened this issue Jan 4, 2021 · 1 comment · Fixed by #1492, #1503 or #1564
Closed

SelectTree 搜索输入框在输入值时候失焦问题 #1491

chownchen opened this issue Jan 4, 2021 · 1 comment · Fixed by #1492, #1503 or #1564
Labels
bug Something isn't working comp:treeselect

Comments

@chownchen
Copy link
Collaborator

chownchen commented Jan 4, 2021

Bug 描述
SelectTree 异步搜索无法实现中文搜索

参考
重现步骤:

  1. 使用 SelectTree 组件,按照官方文档配置好异步dataSource
  2. 搜索任意一个中文,异步请求开始,输入法中断
  3. 只能输入当前的字母,无法输入中文

预期行为
能够支持中文搜索

可重现环境:

  • 系统: [macOS]
  • 浏览器: [chrome]
  • HIUI 的版本: [ 3.3.0]

代码如下:
`
import React from "react"
import SelectTree from "@hi-ui/hiui/es/select-tree"

class Demo extends React.Component {
render() {
return (
<SelectTree
clearable
dataSource={(key) => {
return {
method: "GET",
key: "id",
params: { pId: key },
url: "http://my-json-server.typicode.com/hiui-group/db/fulldata",
transformResponse: (res) => {
return res.map((r) => {
return {
...r,
id: r.code || r.id,
title: r.name || r.title
}
})
}
}
}}
/>
)
}
}
export default Demo
`

补充

在正常的过滤以及筛选功能中也是同样情况

@chownchen chownchen added the bug Something isn't working label Jan 4, 2021
@GleanCoder1116 GleanCoder1116 changed the title SelectTree 异步搜索无法实现中文搜索 SelectTree 异步搜索输入框失焦问题 Jan 4, 2021
@GleanCoder1116 GleanCoder1116 changed the title SelectTree 异步搜索输入框失焦问题 SelectTree 搜索输入框失焦问题 Jan 4, 2021
@GleanCoder1116 GleanCoder1116 changed the title SelectTree 搜索输入框失焦问题 SelectTree 搜索输入框在输入值时候失焦问题 Jan 4, 2021
GleanCoder1116 pushed a commit that referenced this issue Jan 4, 2021
@GleanCoder1116 GleanCoder1116 linked a pull request Jan 4, 2021 that will close this issue
solarjoker added a commit that referenced this issue Jan 5, 2021
@chownchen
Copy link
Collaborator Author

删除第一次的关键词,再次搜索关键词后,选择节点会出现报错
重现步骤:
1 搜索“A”,带出部分值,勾选某一个值后
2 删除搜索值'A',再次搜索关键词‘B’,选择任意一个可选值即可重现
报错信息如下

Uncaught TypeError: Cannot convert undefined or null to object
    at util.js:528
    at Array.map (<anonymous>)
    at clearReturnData (util.js:527)
    at checkedEvents (SelectTreeHook.js:427)
    at onChange (TreeNode.js:85)
    at Checkbox.js:52
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:306)

对应源码位置, node is undefined

var clearReturnData = function clearReturnData(arg) {
  arg = _lodash["default"].cloneDeep(arg);

  if (arg instanceof Array) {
    arg = arg.map(function (node) {
      delete node.ancestors;  //  node is undefined
      delete node.pId;
      return node;
    });
  } else {
    delete arg.ancestors;
    delete arg.pId;
  }

  return arg;
};

GleanCoder1116 pushed a commit that referenced this issue Jan 5, 2021
GleanCoder1116 added a commit that referenced this issue Jan 6, 2021
fix: SelectTree: 微调异步多选报错问题修复 #1491
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working comp:treeselect
Projects
None yet
2 participants