Comments (11)
I can't find the issue in my demo, it works properly, see here, try it.
from tree-select.
I did a little research, and found that the issue happens when I use treeCheckStrictly. The issue also happens when I add treeCheckStrictly to that example code. I'm going to keep looking what cause it, but maybe you have better insight.
from tree-select.
Do you know the reason?
from tree-select.
treeCheckStrictly
is a bit special here, and reference the usage of it here please.
from tree-select.
I think the problem may be in the rc-tree. The scenario is searching and checking a tree node. Without treeCheckStrictly, the tree always returns an array of all selected value. But when turn on treeCheckStrictly, it only returns an array of objects which are rendered in the current tree. In other words, if the tree node has been filtered out by search, we lost the selected value for that node in the state of tree.
from tree-select.
I have a workaround for now, I add a global variable searching
to check if we're doing search or not. Then in onChange()
, union the current and previous selected value together. (fyi. here I introduced unionBy from lodash).
onSearch(value) {
if ( value === "" || value === null ) {
searching = false;
} else {
searching = true;
}
// console.log(value, arguments);
},
onChange(value) {
if (searching) {
console.log('onChange', arguments);
let theValue = this.state.value;
if ( theValue.length > 0 ) {
theValue = unionBy( theValue, value, 'value' );
}
value = theValue;
searching = false;
}
this.setState({ value });
}
note: I think it's better if we can fix this in the lib.
from tree-select.
这个问题我在用的时候也遇到了,看官方demo 有没有问题,props 又比较多, 看ant.design http://ant.design/components/tree-select 第三个有搜索功能的demo 完全不具有参考价值 因为第三个demo 根本没有实现搜索的实际功能,排查了很久,和 rc 的 basic demo 里的 check select 的props 一个一个对比才发现 如果要搜索 必须要传 inputValue={null} 这个props 才会在搜索之后更新数据,所以建议是不是可以考虑把 inputValue 这个props 内部处理了 而不是要让使用者传这么一个写死的 props
from tree-select.
而且现在http://react-component.github.io/tree-select/examples/basic.html 这个demo 里的 check select 也的搜索也是有问题的 搜索之后并不能正确选中 可以尽快修复这个 bug 吗?
from tree-select.
from tree-select.
try [email protected] and demo http://react-component.github.io/tree-select/examples/filter.html
from tree-select.
closing this, as the problem has been fixed.
from tree-select.
Related Issues (20)
- [Feature Request] Allow check parent when no child checked in `treeCheckable` mode
- TypeScript is wrong for onSelect/onDeselect
- tokenSeparators not work
- Have the dropdown be relative to the parent and not the body when on scrollable modal HOT 1
- undocumented breaking change - ref methods focus & blur missing
- [Feature Request] TreeSelect: Add "labelInAriaLive"-property for better accessibility HOT 1
- 有什么办法能实现给每个选择项增加类名吗
- 下拉框内容 横向超出可视范围怎么办?
- Dropdown not rendering HOT 5
- Problem after updating "react-scripts" to "^5.0.1"
- When the dropdown renders on top, elements are unclickable.
- No Working Examples HOT 1
- index.css not found HOT 3
- index.css not found HOT 1
- screen reader HOT 1
- Screen reader announces 'value' prop instead of 'title' or 'aria-label' prop
- Cache causing issues when changing options dynamically. HOT 1
- DFS这里是否能调整为尾递归
- Getting Legacy Context API in react 18
- [mobile] 怎么不让search input每次都自动focus?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tree-select.