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

Toaster component throws errors when Toast is closed if a returnElements is not provided in the calling event #571

Closed
brentswisher opened this issue Jul 28, 2023 · 1 comment · Fixed by #572

Comments

@brentswisher
Copy link
Contributor

brentswisher commented Jul 28, 2023

Expected behavior
There would be no error if returnElements is provided because it defaults to an empty array

Actual behavior
The following error is emitted:

pharos-toaster.js:71 Uncaught TypeError: returnElements is not iterable
    at PharosComponent._focusOnReturnElements (pharos-toaster.js:71:1)
    at PharosComponent._closeToast (pharos-toaster.js:84:1)
    at pharos-toast.js:101:1
    at debounce.js:10:1

Steps to reproduce the issue

  1. Create a toast/toaster by emitting a custom event as detailed in the documentation without including a return element:
const event = new CustomEvent("pharos-toast-open", {
        detail: {
            content: "Some problem has occurred",
            status: "error",
        },
    });
    document.dispatchEvent(event);
  1. Trigger toast to show and then close
  2. See error in browser console

Screenshots or code
I suspect this section is always overwriting the default, even when it isn't defined in the event.

    const { content, status, id, indefinite, returnElements } = (<CustomEvent>event).detail;
    this.returnElements = returnElements;

Pharos version
12.19.2

Your environment

  • OS: macOS Ventura
  • Browser: Chrome
  • Version: 114.0.5735.248
@daneah
Copy link
Member

daneah commented Jul 28, 2023

Context: #503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants