question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
AJIXuMuKcommented, Apr 29, 2020

The documentation has been merged as well.

0reactions
siddharth-vaghasiacommented, Apr 28, 2020

@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}`);
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Release notes - @pnp/spfx-controls-react
... ComboBoxListItemPicker : onSelectedItem passing data to callback method but with attributes value as undefined #519; FilePicker : filename is not ...
Read more >
Passing a variable into a callback function but it's coming up ...
log in clickedCluster keeps coming back undefined. I know it's not undefined because I console logged the variable inside the loadData function ......
Read more >
Memoizing downshift useCombobox callbacks with useCallback
Working on this: https://github.com/downshift-js/downshift/issues/1050.
Read more >
Understand JavaScript Callback Functions and Use Them
We can pass any of the containing function's properties (or global properties) as parameters to the callback function.
Read more >
Callbacks / Callables - Manual - PHP
Callback functions can not only be simple functions, but also object methods, including static class methods. Passing ¶. A PHP function is passed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found