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

ComboBoxListItemPicker - onSelectedItem passing data to callback method but with attributes value as 'undefined' #519

Closed
siddharth-vaghasia opened this issue Mar 30, 2020 · 6 comments
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Milestone

Comments

@siddharth-vaghasia
Copy link
Contributor

Category

[ ] Enhancement

[X ] Bug

[ ] Question

Version

Please specify what version of the library you are using: [ 1.17.0 ]

Expected

While overriding onSelectedItem method we should get an array of the selected items with Id and Title column.

Below is sample implementation.

<ComboBoxListItemPicker listId='ba682bc2-351e-45ae-8cbe-b0512ba0291a' columnInternalName='Title' keyColumnInternalName='Id' // filter="Title eq 'SPFx'" onSelectedItem={this.onSelectedComboBoxItemPicker} webUrl={this.props.context.pageContext.web.absoluteUrl} spHttpClient={this.props.context.spHttpClient} multiSelect={true} />

private onSelectedComboBoxItemPicker(data: { key: string; name: string }[]) { for (const item of data) { console.log(Item value: ${item.key}); console.log(Item text: ${item.name}); } }

Observed Behavior

We are getting Id and Title as undefined in the array. Please refer below screenshot.

image

Further analysis and a possible fix.
image

Reference file = webpack:///../../../../src/controls/listItemPicker/ComboBoxListItemPicker.tsx

Thanks!

@ghost
Copy link

ghost commented Mar 30, 2020

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 label Mar 30, 2020
@RantingLemming
Copy link

RantingLemming commented Mar 31, 2020

Encountered similar issue and came to same conclusion/resolution as @siddharth-vaghasia.

This also seems only applicable to when the multiSelect prop is passed. When not passing multiSelect, no results are returned at all. The value still seems to be returned if I insert a console.log(option) into the above onChanged function, but the else case doesn't return anything as console logging this.selectedItems returns no result, thus line 115 above would likewise result in nothing when you try to filter over it.

@mgwojciech
Copy link

Hi Guys,
Thanks for reporting this. One note (maybe that is not documented well), onSelectedItem always passes selected item, not whole array (same for single and multi select). You can check the details using onSelectedItem={(item) => {
console.log(item);
}}
You will notice that for single selection mode the selected property is undefined and for multi select You will get information if the value was selected or the selection was removed
image
Hope that helps

@AJIXuMuK AJIXuMuK added status:fixed-next-drop Issue will be fixed in upcoming release. type:bug and removed Needs: Triage 🔍 labels Apr 28, 2020
@AJIXuMuK AJIXuMuK added this to the 1.18.0 milestone Apr 28, 2020
@AJIXuMuK
Copy link
Collaborator

Thank all of you for active discussion!
The fix has been merged and available in the beta version.
Could you please test it on your end as well?
Thanks!

@siddharth-vaghasia
Copy link
Contributor Author

@AJIXuMuK ...thanks...tested this...it is working as expected if we write call back with below syntax

private onSelectedComboBoxItemPicker(items:[]) {
    console.log("selected items:", items);
     }
  }

Call back method documented in markup is below, which won't copy values in key and name unless it is passed in the same format.... So I believe we should update the documentation to the above syntax. submitting a PR for same, please merge it if it make sense..!!

private onSelectedItem(data: { key: string; name: string }[]) {
  for (const item of data) {
    console.log(`Item value: ${item.key}`);
    console.log(`Item text: ${item.name}`);
  }
}

@AJIXuMuK
Copy link
Collaborator

The documentation has been merged as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:fixed-next-drop Issue will be fixed in upcoming release. type:bug
Projects
None yet
Development

No branches or pull requests

4 participants