Code Monkey home page Code Monkey logo

Comments (11)

warmhug avatar warmhug commented on June 12, 2024

I can't find the issue in my demo, it works properly, see here, try it.
image

from tree-select.

codTango avatar codTango commented on June 12, 2024

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.

warmhug avatar warmhug commented on June 12, 2024

Do you know the reason?

from tree-select.

warmhug avatar warmhug commented on June 12, 2024

treeCheckStrictly is a bit special here, and reference the usage of it here please.
image

from tree-select.

codTango avatar codTango commented on June 12, 2024

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.

codTango avatar codTango commented on June 12, 2024

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.

winterJIE avatar winterJIE commented on June 12, 2024

这个问题我在用的时候也遇到了,看官方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.

winterJIE avatar winterJIE commented on June 12, 2024

而且现在http://react-component.github.io/tree-select/examples/basic.html 这个demo 里的 check select 也的搜索也是有问题的 搜索之后并不能正确选中 可以尽快修复这个 bug 吗?

from tree-select.

yiminghe avatar yiminghe commented on June 12, 2024

@warmhug

from tree-select.

warmhug avatar warmhug commented on June 12, 2024

try [email protected] and demo http://react-component.github.io/tree-select/examples/filter.html

from tree-select.

codTango avatar codTango commented on June 12, 2024

closing this, as the problem has been fixed.

from tree-select.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.