SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 998 forks source link

List Formatting: Opening and closing a group changes the values of other groups (`@group.fieldData`) #9794

Closed tecchan1107 closed 1 week ago

tecchan1107 commented 1 month ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

Declarative list formatting

Developer environment

None

What browser(s) / client(s) have you tested

Additional environment details

No response

Describe the bug / error

In the formatting of the view, I am using @group.fieldData to display the data in the grouped columns. image

When I open or close a group, the values of the other groups change.

image

group

Related Document: Group customization syntax reference

Steps to reproduce

  1. Set up the first and second groups in the view setting image

  2. Set the following JSON to view formatting

    Sample Code ``` json { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json", "groupProps": { "headerFormatter": { "elmType": "div", "style": { "cursor": "pointer", "padding": "5px 10px", "border-radius": "5px" }, "attributes": { "class": "ms-bgColor-themeLighter--hover" }, "children": [ { "elmType": "span", "txtContent": "@group.fieldData" }, { "elmType": "span", "txtContent": "=' ('+@group.count+')'" } ] } } } ```

    image

Expected behavior

Opening and closing a group does not change the values of other groups.

the-last-day commented 1 month ago

Hi, I also reproduce the error, and I can give one more details. You need to have 2 level of grouping to seen the bug. And If the subgroup that you unfold/fold has only 1 item, the bug does not appear. As soon as you you unfold/fold a subgroup that has 2 or more item, it appears. And the way the groups and subgroups are renamed by the bug is linked to the number of items in the group or subgroup. image In this exemple I unfold and fold the 1st subgroup "Row colors gray" which has 3 items. image Then the 3 1st subgroups are renamed "Row colors gray", but they each keeps their correct item count. And all next subgroup have been shifted and duplicated according to their item count. Really strange.

Here is the JSON code I used : "groupProps": { "headerFormatter": { "elmType": "div", "txtContent": "=@group.fieldData.displayValue + ' ' + @group.count" } }

arkogupta commented 1 week ago

@tecchan1107 Can you please confirm if the fix has reached your tenant?

tecchan1107 commented 1 week ago

@arkogupta I checked with my tenant and this issue has been resolved! Thanks for the fix and for letting me know!!

sample

I will close this issue.

JoeAyre commented 1 week ago

Hi @arkogupta - as the person who originally reported this strange behaviour (https://github.com/pnp/List-Formatting/issues/818), I thought I would add that I too have checked whether the fix has reached our tenant, and can confirm that it has. Thanks for the fix, and thanks again, @tecchan1107 for taking the time to document the issue in here.