palantir/blueprint

MultiSelect2: createNewItemFromQuery is called redundantly

开放

#5,992 创建于 2023年3月2日

 (0 条评论) (0 个反应) (0 位负责人)TypeScript (2,167 个派生)batch import
P3Package: selectType: bughelp wanted

仓库指标

星标
 (20,263 个星标)
PR 合并指标
 (平均合并 43天 10小时) (30 天内合并 27 个 PR)

描述

As the documentation says, createNewItemFromQuery "invoked when user interaction causes one or many items to be created, either by pressing the Enter key or by clicking on the "Create Item" option". But in fact, the function is called once the MultiSelect2 component is initialized. Related code here: https://github.com/palantir/blueprint/blob/abd066f2e0221cb4c219004727a8ddba7c2b7d5b/packages/select/src/components/query-list/queryList.tsx#L211

Environment

  • Package version(s): 4.9.3
  • Operating System: Windows 11
  • Browser name and version: Latest Chrome

Code Sandbox

Link to a minimal repro: https://codesandbox.io/s/nifty-hawking-oucqgc

Steps to reproduce

  1. Open console panel
  2. "createNewItemFromQuery is called!" is printed without any interactions.

Actual behavior

createNewItemFromQuery is called without user interactions.

Expected behavior

createNewItemFromQuery should be only invoked when user interaction causes one or many items to be created, either by pressing the Enter key or by clicking on the "Create Item" option.

Possible solution

Make the initial value of state.createNewItem to undefined?

贡献者指南