sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

sp-dialog crashes when it is opened twice

Open jmmartinez84 opened this issue 8 years ago • 12 comments

Category

  • [ ] Question
  • [ ] Typo
  • [X] Bug
  • [ ] Additional article idea

Using spfx 1.7 I've created a custom confirm/cancel dialog.

Expected or Desired Behavior

You can open/close a dialog a much times as you want.

Observed Behavior

When you open the dialog first time it works fine, but when you try to open int again. it shows the grey layout and an error on the console.

react-dom.development.js:526 Warning: render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.
printWarning @ react-dom.development.js:526

Steps to Reproduce

Create a new spfx 1.7 Online project. Add a custom dialog component. Test it on workbench page. Try to open the dialog twice.

jmmartinez84 avatar Nov 21 '18 07:11 jmmartinez84

+1. Seeing the same with 1.7. The same behavior is visible when the web part is deployed to the actual page.

jansenbe avatar Nov 27 '18 16:11 jansenbe

@jmmartinez84 Thanks for filing the issue.

@jmmartinez84 @jansenbe You can work around this right now by overriding the onAfterClose method with the following snippet:

// In the derived class
protected onAfterClose(): void {
  super.onAfterClose();
  ReactDOM.unmountComponentAtNode(this.domElement);
}

johnguy0 avatar Nov 30 '18 19:11 johnguy0

Hey @jmmartinez84 - quick question on this. Did you update your solution to use React16 to see this, or did you continue to use React15 and this started happening?

patmill avatar Nov 30 '18 19:11 patmill

I created a brand new project on SPFx 1.7 + React 16

jmmartinez84 avatar Nov 30 '18 20:11 jmmartinez84

This workaround does not work in IE. If you open it in IE the second time it crashes again. IE seems to remove the div completely.....

OliverZeiser avatar Dec 11 '18 11:12 OliverZeiser

My workaround right now that also works in IE: Make the Dialog blocking and call ReactDOM.unmountComponentAtNode before closing the dialog and not inside onAfterClose. This works in all Browsers that I have testet.

OliverZeiser avatar Dec 11 '18 14:12 OliverZeiser

Very actual issue

aslanovsergey avatar Jan 16 '19 07:01 aslanovsergey

Having same(as shown below) issue in IE. Works perfect in Chrome and Edge. Using SPFx 1.7.1 + React 16.3.2. Above workarounds did not work for me. Can anyone share the working code?

NotFoundError { [functions]: , proto: { }, ABORT_ERR: 20, code: 8, constructor: { }, DATA_CLONE_ERR: 25, DOMSTRING_SIZE_ERR: 2, HIERARCHY_REQUEST_ERR: 3, INDEX_SIZE_ERR: 1, INUSE_ATTRIBUTE_ERR: 10, INVALID_ACCESS_ERR: 15, INVALID_CHARACTER_ERR: 5, INVALID_MODIFICATION_ERR: 13, INVALID_NODE_TYPE_ERR: 24, INVALID_STATE_ERR: 11, message: "NotFoundError", name: "NotFoundError", NAMESPACE_ERR: 14, NETWORK_ERR: 19, NO_DATA_ALLOWED_ERR: 6, NO_MODIFICATION_ALLOWED_ERR: 7, NOT_FOUND_ERR: 8, NOT_SUPPORTED_ERR: 9, PARSE_ERR: 81, QUOTA_EXCEEDED_ERR: 22, SECURITY_ERR: 18, SERIALIZE_ERR: 82, SYNTAX_ERR: 12, TIMEOUT_ERR: 23, TYPE_MISMATCH_ERR: 17, URL_MISMATCH_ERR: 21, VALIDATION_ERR: 16, WRONG_DOCUMENT_ERR: 4 }

muthugp avatar May 23 '19 00:05 muthugp

Suffering from this right now. @OliverZeiser can you please show your code? I look at the BaseDialog and did not find onBeforeClose.

DanSantoDomingo avatar May 23 '19 01:05 DanSantoDomingo

Just do something like this:

export default class CustomMessageDialog extends BaseDialog {
  public message: string;
  public title: string;
  public render(): void {
    ReactDOM.render(<CustomMessageContent
      close={this.closeDialog.bind(this)}
      title={this.title}
      message={this.message}
    />, this.domElement);
  }
  
  private closeDialog(): void {
    this.close();
    ReactDOM.unmountComponentAtNode(this.domElement);
  }

OliverZeiser avatar May 23 '19 06:05 OliverZeiser

This was fixed a while ago, but you do need to un mount your component via the onDispose method.

patmill avatar Oct 04 '21 19:10 patmill

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

ghost avatar Oct 12 '21 00:10 ghost