SharePoint / SharePoint/sp-dev-docs

Issue with two separate ListView Command Set extensions in List WebPart

Open
#10,808 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PowerShell
Stars
1.4k
Forks
1.1k
Avg merge
4d 12h
Merged PRs (30d)
12

Description

Description

I observed a strange behavior with Command Set extensions in a (standard) List WebPart.

If you are using two different CSEs on a list, it works perfectly fine on the list itself. But if that list is embedded in a (standard) List WebPart, the buttons won't render most of the time. Sometimes it only renders one button (CSE A), but not the other (CSE B).

After some digging I realized that CSE A registers an async method on the listViewStateChangedEvent.

private _onListViewStateChanged = async (args: ListViewStateChangedEventArgs): Promise<void>

CSE B does register a normal method (because it doesn't need it). The funny thing: the event still triggers and sets the button to visible, but the button won't render. And yes, I do call this.raiseOnChange();

private _onListViewStateChanged = (args: ListViewStateChangedEventArgs): void

After making that one also async, it worked perfectly fine.

Steps to reproduce
  1. Deploy two ListView Command Set extensions, one with an async _onListViewStateChanged method and one as a default _onListViewStateChanged method. Set the initial button visibility for both to false. Set the buttons to visible in the event if 1 or more items have been selected.
  2. Embed the list in default SharePoint List WebPart on any page
  3. Refresh the site. Most of the time you won't see any button after selecting item(s). Sometimes only the one with an async event.
  4. Hard Refresh the site, you will see both buttons
  5. If you soft refresh again and you will see the same problem as in step 4
  6. Change the second _onListViewStateChanged to an async
  7. Works perfectly fine now
Expected behavior

Setting a button to visible should make it visible, no matter if the event is registered as an async or not

Actual behavior

Button visibility property will be set to visible, but it won't render at all.

CLI version

1.22.1

Node.js version

v22.19.0

Operating system

Windows

Template (if applicable)

No response

Additional context

No response

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.

Research direction

Start by reproducing the issue with two ListView Command Set extensions embedded in a standard List WebPart, using _onListViewStateChanged with one async and one normal handler. Inspect how listViewStateChangedEvent and raiseOnChange() update and render button visibility. Done means both buttons render consistently after selection and refresh regardless of whether the handlers are async.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.