SharePoint / SharePoint/sp-dev-docs

selectedRows is null on initial run of _onListViewStateChanged

Open
#10,100 5 comments 0 reactions 1 assignee View on GitHub

@Ashlesha-MSFT is already working on this.

Since Mar 4, 2025.

sharepoint-developer-support type:bug-confirmed type:bug-suspected
Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

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
  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)
Additional environment details
  • Edge Version 132.0.2957.140
  • SPFx version 1.20.0
  • Node.js version 18.17.1
  • "New modern", "Post modern", "New new" - or whatever you want to call the new list layout
Describe the bug / error

I'm building a List View Command Set extension

When the page is loaded my, and my _onListViewStateChanged(....) function is run for the first time, the this.context.listView.selefctedRows is undefined, rather than an empty array, this change seemingly happened over night.

Steps to reproduce

Once you create a new List View Command Set extension the _onListViewStateChanged is added automatically, flip the logic as such: compareOneCommand.visible = this.context.listView.selectedRows.length === 0 and you should observe the behaviour

Expected behavior

this.context.listView.selectedRows should be an empty array if no rows are selected, even upon the first run.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.