react-picky 如何在过滤器中包含 "Select all"?

react-picky how to include the "Select all" in the Filter?

我在一个项目中使用了 react-picky (react-picky) 并且非常喜欢它。一个快速的问题是:一旦我使用 "Filter" 字段,"Select All" 选项就会消失。我希望在使用过滤器时最终拥有 "Select All",这样我就可以 select 所有过滤的选项。 谁能帮我完成那个?非常感谢!

非常好的工具,我发现有 if(multiple && !filtered) {...} 所有你需要做的删除条件 && !filtered then select all still appear.here an example:

          <Picky
          value={this.state.arrayValue}
          options={bigList}
          onChange={this.selectMultipleOption}
          open={true}
          valueKey="id"
          labelKey="name"
          multiple={true}
          includeSelectAll={true}
          includeFilter={true}
          dropdownHeight={600}
          renderSelectAll={({
            filtered,
            tabIndex,
            allSelected,
            toggleSelectAll,
            multiple,
          }) => {
            // removed && !filter from the condition to keep select all appear
            if (multiple ) {
              return (
                <div
                  tabIndex={tabIndex}
                  role="option"
                  className={allSelected ? 'option selected' : 'option'}
                  onClick={toggleSelectAll}
                  onKeyPress={toggleSelectAll}
                >
                  <h5>SELECT ALL</h5>
                </div>
              );
            }
          }}
        />

现在可以使用 selectAllMode='filtered' 属性开箱即用。

这将在过滤时显示 "Select All" 框,并确保仅选择过滤后的选项。