Navigating to a non-list page (e.g. Home.aspx) breaks sp-dialog in ListViewCommandSet extensions
Category
- [x] Bug
Describe the bug
Foreword, I'm still new to SPFx, so I'm only 90% sure this isn't a problem of my own creation.
I'm using sp-dialog from a ListViewCommandSet extension that is globally deployed in our tenant. I've found that when either starting on the home page for a site collection, or when navigating there via the quicklaunch and then returning to a list view, I am unable to show a dialog from code. Calling .show() on my dialog object causes the following to be thrown:
Error: The value for "domElement" must not be undefined
at Function.e.isNotNullOrUndefined (listview-host-assembly_en-au_00afc0073cca38c5d0f0151bba60e1ad.js:1)
at e.get [as domElement] (listview-host-assembly_en-au_00afc0073cca38c5d0f0151bba60e1ad.js:1)
at new e (sp-dialog_none_e0cea20ae3bf94a90037.js:1)
at Function.get [as instance] (sp-dialog_none_e0cea20ae3bf94a90037.js:1)
at ApproverPickerDialog.e.show (sp-dialog_none_e0cea20ae3bf94a90037.js:1)
at ApprovalButtonCommandSet.uGvk.ApprovalButtonCommandSet.onExecute (ApprovalButtonCommandSet.ts:182)
at e.execute (listview-host-assembly_en-au_00afc0073cca38c5d0f0151bba60e1ad.js:1)
at deferred.items-view.chunk.js:1
at plt.listviewdataprefetch.standalone.chunk.js:2
at Object.next (plt.listviewdataprefetch.standalone.chunk.js:2)
Steps to reproduce
- Create a new ListViewCommandSet project
- Add a sp-dialog file, see below for a simple example
- In the onExecute method for your command set, create an instance of your dialog and call .show(), making sure to wrap it in a try-catch to show the exception in the console.
- Either deploy the project or use gulp serve
- After loading a page where the button exists, click it, and observe the dialog
- Navigate to the home page for the site collection
- Navigate back to the list and click the button
- See error
// WaitDialog.tsx
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { BaseDialog, IDialogConfiguration } from '@microsoft/sp-dialog';
import {
Spinner,
SpinnerSize,
DialogContent
} from 'office-ui-fabric-react';
interface IWaitDialogContentProps {
message: string;
}
class WaitDialogContent extends React.Component<IWaitDialogContentProps, {}> {
constructor(props) {
super(props);
}
public render(): JSX.Element {
return <DialogContent
showCloseButton={false}
>
<Spinner size={SpinnerSize.large} label={this.props.message} />
</DialogContent>;
}
}
export default class WaitDialog extends BaseDialog {
public message: string;
public render(): void {
ReactDOM.render(<WaitDialogContent
message={this.message || "Please wait..."}
/>, this.domElement);
}
public getConfig(): IDialogConfiguration {
return {
isBlocking: false
};
}
protected onAfterClose(): void {
super.onAfterClose();
// Clean up the element for the next dialog
ReactDOM.unmountComponentAtNode(this.domElement);
}
}
Expected behavior
I would expect no exceptions to occur based on which order users navigate SP pages.
Environment details (development & target environment)
- Your Developer Environment: Windows 10
- Target Environment: SharePoint Online
- Framework: Node.js v6
- Browser(s): Chrome v85 / Chromium Edge v85
- Tooling: VS Code + SPFx v1.11.0
- Additional details:
"dependencies": {
"@microsoft/decorators": "1.11.0",
"@microsoft/sp-core-library": "1.11.0",
"@microsoft/sp-dialog": "1.11.0",
"@microsoft/sp-listview-extensibility": "1.11.0",
"@pnp/common": "^2.0.6",
"@pnp/logging": "^2.0.6",
"@pnp/odata": "^2.0.6",
"@pnp/sp": "^2.0.6",
"@pnp/spfx-controls-react": "^1.19.0",
"@types/es6-promise": "0.0.33",
"@types/webpack-env": "1.15.2",
"office-ui-fabric-react": "^7.121.9"
},
"devDependencies": {
"@microsoft/rush-stack-compiler-3.3": "0.3.5",
"@microsoft/sp-build-web": "1.11.0",
"@microsoft/sp-module-interfaces": "1.11.0",
"@microsoft/sp-tslint-rules": "1.11.0",
"@microsoft/sp-webpart-workbench": "1.11.0",
"@types/chai": "3.4.34",
"@types/mocha": "2.2.38",
"ajv": "~5.2.2",
"gulp": "~3.9.1"
}
Additional context
Thanks for your contribution! Sharing is caring.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Hello,
This just started happening in a customer's tenant. No error messages are displayed directly, but I found the error you're describing in the call to SPO metrics (browser.pipe.aria ...). After some waiting and a few reloads, it works - however this is not acceptable for our customer. Navigating directly to the document library (without visiting a site page) works exactly the way you described and is, at least, a temporary workaround while we figure out when this started and set up a support case.
Hi
Has there been any progress on this? We recently went live for a client that is reliant on this functionality and they too are now seeing this behavior. While going to the document library directly or getting the user to refresh the document library is a short term fix, longer term it is unsustainable.
We are also seeing this issue... was there any resolution other than refreshing the page?
@dabanks @teresahoes - could you please provide some steps to repro?
I used the code provided by @dixonte and showed dialog onExecute - and it seems to work fine after navigating back and forth.
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
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