SPFx Custom Command Bar button: How do I get the list information?

Copper Contributor


I have a custom SPFx Extension that adds a new Command Bar button for lists and libraries. It works  great with all backend list and libraries where users can fill out the panel that opens and the user's data entry + list information get correctly written to another place.

All that works great... when you go directly to the lists/libraries from Site Contents.

However, if a List webpart is added to a Modern page in the Site Pages library, then the list information from the page context references the Site Pages library instead of the list/library that's being viewed within that page.

How can I get the list information passed back to my panel from the Command Bar button? I've poured over the context javascript variables and I the only reference to the actual list being displayed is under this.context.listView.adapter.list, but it doesn't seem like that can be used in the react code.

Any tips or suggestions would be welcome at this point, thanks.

1 Reply

@BlubbyMunkey What kind of list information you need to command bar code (like list title, list ID, etc.)?


Also, if you can read the values from SPFx context (this.context.listView.adapter.list), what is the problem while using it in your code?

Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.