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

Cannot read property 'zoneEmphasis' of undefined in ClientSidePage.fromFile #1111

Closed
kavaghela opened this issue Mar 16, 2020 · 3 comments · Fixed by #1137
Closed

Cannot read property 'zoneEmphasis' of undefined in ClientSidePage.fromFile #1111

kavaghela opened this issue Mar 16, 2020 · 3 comments · Fixed by #1137

Comments

@kavaghela
Copy link

kavaghela commented Mar 16, 2020

  • [- ] Bug

PNJ Version : [ 1.3.0 ]

SharePoint Version: [SharePoint 2019 On Premise ]

I have created brand new spfx web part for SharePoint 2019 and then installed following pnp packages

npm install @pnp/logging@1.3.10 @pnp/common@1.3.10 @pnp/odata@1.3.10 @pnp/sp@1.3.10 -
-save

Now I want to read web parts added in particular client side page. hence I used following code.

In Main Web Part File I have added below code

 public onInit(): Promise<void> {
    return new Promise<void>((resolve) => {
      sp.setup({
        spfxContext: this.context
      });
      resolve();


    });
  }

In my component, I am using following code

 ClientSidePage.fromFile(sp.web.getFileByServerRelativeUrl("/sites/spfx/SitePages/List-Form.aspx")).then(
      (page) => {
        console.log(page);
      }
    );    

Expected / Desired Behavior / Question

It should me return details of client side page.

Observed Behavior

It gives me following error:

Uncaught (in promise) TypeError: Cannot read property 'zoneEmphasis' of undefined
at ClientSidePage.mergePartToTree (clientsidepages.ts:796)

It gives error in following function from clientsidepages.ts. I have added comments where it gives error.

private mergePartToTree(control: any, positionData: IPosition): void {

        let column: CanvasColumn = null;
        let sectionFactor: CanvasColumnFactor = 12;
        let sectionIndex = 0;
        let zoneIndex = 0;
        let layoutIndex = 1;

        // handle case where we don't have position data (shouldn't happen?)
        if (positionData) {
            if (hOP(positionData, "zoneIndex")) {
                zoneIndex = positionData.zoneIndex;
            }
            if (hOP(positionData, "sectionIndex")) {
                sectionIndex = positionData.sectionIndex;
            }
            if (hOP(positionData, "sectionFactor")) {
                sectionFactor = positionData.sectionFactor;
            }
            if (hOP(positionData, "layoutIndex")) {
                layoutIndex = positionData.layoutIndex;
            }
        }
// Gives Error here
  const section = this.getOrCreateSection(zoneIndex, layoutIndex, control.data.emphasis.zoneEmphasis || 0);

  const columns = section.columns.filter(c => c.order === sectionIndex);
        if (columns.length < 1) {
            column = section.addColumn(sectionFactor, layoutIndex);
        } else {
            column = columns[0];
        }

        control.column = column;
        column.addControl(control);

As per #735 It should be resolved in version 1.3.10.

Sample project can be found in below https://github.com/kavaghela/SPFX/tree/master/OnPremiseTest1

Could you please someone help here?

@patrick-rodgers
Copy link
Member

So it seems in your case the entire emphasis object is undefined. I don't have a way to test on-premises but my guess is this is a difference in the implementation between SPO and the version you have locally. I can add a check for that easy enough but don't have a way to really test it. Are you able to test a beta version once published?

@tntboneman
Copy link

Hi Patrick, Has it been tested in SharePoint 2019 On Premise already?
I'm in the same trouble now and feel confused.
QQ截图20200828155436
QQ截图20200828155549
QQ截图20200828155826
QQ截图20200828155902

@github-actions
Copy link

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.

@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants