Skip to content

Breaking change in SPFx dynamic data consuming page environment data (started June 23rd 2020) #5947

@wobba

Description

@wobba

Category

  • Bug

Describe the bug

June 23rd a change happened which caused DynamicProperty.tryGetValue() to return an object instead of a string. This has had a severe impact on PnP Modern Search web part scenario's which use this functionality. It's not related to search, but to use of any of the page environment properties.

The failing line in the sample below is value = this.properties.foo.tryGetValue(); which was expected to return a string, which now has to be parsed.

It's ok to have a change, but should then be tied to a newer release of SPFx.

Create a web part with the sample code, configure to use Dynamic data via any page environment. Using local workbench you get a string, using hosted workbench you get an object. We're tracking the issue at microsoft-search/pnp-modern-search#325

import { Version } from '@microsoft/sp-core-library';
import { IPropertyPaneConfiguration, PropertyPaneDynamicField } from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart, IWebPartPropertiesMetadata } from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset';
import * as strings from 'DdTestWebPartStrings';
import { DynamicProperty } from '@microsoft/sp-component-base';

export interface IDdTestWebPartProps {
    foo: DynamicProperty<string>;
}

export default class DdTestWebPart extends BaseClientSideWebPart<IDdTestWebPartProps> {
    public render(): void {

        let value = "";
        if (this.properties && this.properties.foo) {
            value = this.properties.foo.tryGetValue();
        }

        this.domElement.innerHTML = `
      <div>
        ${escape(value)}
      </div>`;
    }

    protected get propertiesMetadata(): IWebPartPropertiesMetadata {
        return {
            'foo': {
                dynamicPropertyType: 'string'
            }
        };
    }

    protected get dataVersion(): Version {
        return Version.parse('1.0');
    }

    protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
        return {
            pages: [
                {
                    header: { description: strings.PropertyPaneDescription },
                    groups: [{
                        groupName: strings.BasicGroupName,
                        groupFields: [PropertyPaneDynamicField('foo', { label: strings.DescriptionFieldLabel })
                        ]
                    }]
                }
            ]
        };
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:spfxCategory: SharePoint Framework (not extensions related)status:fixed-next-dropIssue planned to be fixed in an upcoming release.status:to-be-reviewedIssue needs to be reviewed by Microsoft for additional follow up / review.status:trackedCurrently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed)type:bug-suspectedSuspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions