Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPFX ListViewCommandSet - this.context.listView.selectedRows is wrong in grouped lists #8379

Closed
2 of 9 tasks
diabhoil opened this issue Aug 18, 2022 · 6 comments
Closed
2 of 9 tasks
Assignees
Labels
area:spfx Category: SharePoint Framework (not extensions related) Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. no-recent-activity Stale issue due to lack of activity. Closed after 7 days with no activity by OP.
Milestone

Comments

@diabhoil
Copy link

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

  • browser version: "newest" versions of chrome and edge
  • SPFx version: 1.15.2
  • Node.js version 14.17.0
  • etc

Describe the bug / error

When having a grouped list view the array "this.context.listView.selectedRows" is containing sometimes the wrong rows. The first group seems to work, but the 2nd group looks wrong. In the array is always the item with the same index of the "selected group" but from the first group. In the linked image the 2nd item from the 3rd group is selected. But in selectedRows is the 2nd item from the first group. This behavior is a problem when one want to check something in a method other then the onExecute (where you can use the event parameter to have a workaround).

image

Steps to reproduce

  1. Create the "default" spfx ListViewCommandSet extension
  2. Create a list in SharePoint and add a view which is grouped by one or two rows
  3. Change the code of the extension a bit to return the title (or any other column) of the selected item in onExecute or in _onListViewStateChanged. For example like this:
public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
    let valueByEvent;
    let valueByContext;
    switch (event.itemId) {
      case 'COMMAND_1':
        valueByEvent = event.selectedRows[0].getValueByName("Title");
        valueByContext = this.context.listView.selectedRows[0].getValueByName("Title");
        Dialog.alert(`ByEvent: ${valueByEvent}, ByContext: ${valueByContext}`).catch(() => {
          /* handle error */
        });
        break;
      case 'COMMAND_2':
        Dialog.alert(`${this.properties.sampleTextTwo}`).catch(() => {
          /* handle error */
        });
        break;
      default:
        throw new Error('Unknown command');
    }
  }
  1. Run the code (gulp serve) on the list with the grouped view
  2. Select an item in another group then the first one
  3. the output should look like this
    image

Expected behavior

Expected would be that this.context.listView.selectedRows contains the rows which are selected (the array should contain the same values like the parameter of onExecute (event: IListViewCommandSetExecuteEventParameters, event.selectedRows).

@diabhoil diabhoil added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Aug 18, 2022
@ghost
Copy link

ghost commented Aug 18, 2022

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 Awaiting categorization and initial review. label Aug 18, 2022
@AJIXuMuK AJIXuMuK added area:spfx Category: SharePoint Framework (not extensions related) and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Aug 18, 2022
@AJIXuMuK AJIXuMuK self-assigned this Aug 18, 2022
@AJIXuMuK
Copy link
Collaborator

@diabhoil - thank you for reporting this issue!
The fix has been done and will be rolled out in the next couple of weeks.

@AJIXuMuK AJIXuMuK removed the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Aug 23, 2022
@AJIXuMuK AJIXuMuK added this to the 08-26 milestone Aug 23, 2022
@flaviuc
Copy link
Contributor

flaviuc commented Sep 13, 2022

@AJIXuMuK did the fix roll out?

@AJIXuMuK
Copy link
Collaborator

@flaviuc - yes, it should be in PROD now.
Are you still seeing the issue?

@AJIXuMuK AJIXuMuK added the Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. label Sep 13, 2022
@ghost ghost added the no-recent-activity Stale issue due to lack of activity. Closed after 7 days with no activity by OP. label Sep 20, 2022
@ghost
Copy link

ghost commented Sep 20, 2022

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within the next 7 days of this comment. Please see our wiki for more information: Issue List Labels: Needs Author Feedback & Issue List: No response from the original issue author

@ghost ghost closed this as completed Sep 27, 2022
@ghost
Copy link

ghost commented Sep 27, 2022

Closing issue due to no response from the original author. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: No response from the original issue author

@ghost ghost locked and limited conversation to collaborators Sep 27, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:spfx Category: SharePoint Framework (not extensions related) Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. no-recent-activity Stale issue due to lack of activity. Closed after 7 days with no activity by OP.
Projects
None yet
Development

No branches or pull requests

3 participants