Skip to content

Sending a non-serializable modal context causes obtuse error message #10

@Blackbaud-ChristiSchneider

Description

I think the scope of this fix should just be to supply a useful error message such as "Non-serializable modal context not supported".

If I attempt to pass a function to the modal context, I get the error: DOMException: Failed to execute 'postMessage' on 'Window': function () { } could not be cloned.

Example code:

import { Component, Injectable } from '@angular/core';
import { SkyAppConfig } from '@skyux/config';
import { SkyAddinModalService } from '@blackbaud-internal/skyux-lib-addin-host';
import { AddinCloseModalArgs } from '@blackbaud-internal/sky-addin-host';
import { Router } from '@angular/router';

@Component({
  selector: 'example',
  templateUrl: './example.component.html'
})
@Injectable()
export class ExampleComponent {

  constructor(
    private skyAppConfig: SkyAppConfig,
    private skyAddinModalService: SkyAddinModalService,
    private router: Router
  ) { }

  public openExampleModal() {

    this.skyAddinModalService.openModal({
      id: 'Example Modal',
      url:
        `https://renxt.blackbaud.com/addins/addconstituent?envid=${this.skyAppConfig.runtime.params.get('envid')}&internalmodal=true`,
      modalMetadata: {
        context: {
          duplicateSelectedHandler: function () { }
        }
      }
    })
    .then((args: AddinCloseModalArgs) => {
      console.log(JSON.stringify(args));
    });
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions