Open martinlingstuyl opened 2 months ago
Some extra information: The following function has the same issues:
@override
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
const compareOneCommand: Command = this.tryGetCommand('COMMAND_1');
if (compareOneCommand) {
// This command should be hidden unless exactly one row is selected.
compareOneCommand.visible = event.selectedRows.length === 1;
}
}
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
Windows
What browser(s) / client(s) have you tested
Additional environment details
Describe the bug / error
I have build several ListView Command Set that interact with selected items on a list. Recently, the new Microsoft Lists design appears to be rolling out on SharePoint lists. After this change, some of our Command Sets stopped working. When I tried it out in development it turns out that
event.selectedRows
is an empty array, so if you have a ListView Command Set that uses selected items, they no longer work.I'm talking about the new list experience in SharePoint. The following is no longer working: selecting an item and triggering a Command Set on that item:
This is that part of (boilerplate code) that stopped working:
There is a workaround
I can work around this by accessing the selectedRows through the context object:
this.context.listView.selectedRows
Steps to reproduce
Use the getting started guide
Update the
onExecute
method from the code section with the following:Serve the command set... and interact with it. It should now trigger a dialog saying you have selected 0 items.
Expected behavior
I'd expect the selectedRows property to work correctly, as it is part of the
IListViewCommandSetExecuteEventParameters
interface.