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

destinationElement null or undefined exception #614

Open
alexdiliberto opened this issue May 17, 2021 · 9 comments
Open

destinationElement null or undefined exception #614

alexdiliberto opened this issue May 17, 2021 · 9 comments

Comments

@alexdiliberto
Copy link

alexdiliberto commented May 17, 2021

Uncaught (in promise) Error: Assertion Failed: You cannot pass a null or undefined destination element to in-element
    at assert (index.js:172)
    at InElementNullCheckReference.value (index.js:5796)
    at Object.evaluate (runtime.js:2288)
    at AppendOpcodes.evaluate (runtime.js:1571)
    at LowLevelVM.evaluateSyscall (runtime.js:4989)
    at LowLevelVM.evaluateInner (runtime.js:4945)
    at LowLevelVM.evaluateOuter (runtime.js:4937)
    at JitVM.next (runtime.js:5992)
    at JitVM.execute (runtime.js:5964)
    at TemplateIteratorImpl.sync (runtime.js:6124)

There may be other ways to trigger this, but you will definitely see the issue if you use this in conjunction with Ember Power Select. Create a new app and add the following respectively to your application controller and application template

import Controller from '@ember/controller';

export default class ApplicationController extends Controller {
  names = ['One', 'Two', 'Three']
}
<PowerSelect
  @searchEnabled={{true}}
  @options={{this.names}}
  @selected={{this.name}}
  @placeholder="Select some names..."
  @initiallyOpened={{true}}
  @onChange={{fn (mut this.name)}} as |name|>
  {{name}}
</PowerSelect>

@initiallyOpened={{true}} is the issue here. I traced the issue down to this line: https://github.com/cibernox/ember-basic-dropdown/blob/v3.0.17/addon/templates/components/basic-dropdown-content.hbs#L4

this.destinationElement is null at this moment and will throw when attempting to render into ember-basic-dropdown-wormhole DOM element since that is rendering later in DOM ordor (at the end of the page)

I took at stab at updating to ensure destinationElement is populated but not sure if this will cause any additional issues. Perhaps someone with a bit more intimate knowledge here will be able to advise.

  @tracked destinationElement: Element | null;

  constructor(owner: unknown, args: Args) {
    super(owner, args);

    this.destinationElement = null;
    next(() => {
      this.destinationElement = document.getElementById(this.args.destination);
    });
  }

this is related to cibernox/ember-power-select#1354

@jgadbois
Copy link

jgadbois commented Jun 2, 2021

I am getting the same error when using named blocks.

@cibernox
Copy link
Owner

cibernox commented Jun 2, 2021

Can you write a reproduction on a test? This is probably easy to fix with a repro on a test.

alexdiliberto added a commit to alexdiliberto/ember-basic-dropdown that referenced this issue Jun 3, 2021
@alexdiliberto
Copy link
Author

@cibernox See #619

@jgadbois
Copy link

I am getting the error using a very basic dropdown directly in the application.hbs.

<BasicDropdown as |dd|
>
  <dd.Trigger>TEST</dd.Trigger>
  <dd.Content>CONTENT</dd.Content>
</BasicDropdown>

@renderInPlace={{true}} fixes it, but breaks when rendered on the body.

@jgadbois
Copy link

Reverting to 3.0.18 fixed this for me

@jherdman
Copy link

jherdman commented Oct 6, 2021

Is there a solution outside of @renderInPlace={{true}}?

@josemarluedke
Copy link
Contributor

Also seeing this error.

@sacarino
Copy link

Ran into this as well. Based on this and cibernox/ember-power-select#1354, I was able to get this workaround going in tests.

<PowerSelect
  // other args
  @initiallyOpened={{false}}
  @renderInPlace={{true}}
  as |stuff|
>
  {{stuff.andThings}}
</PowerSelect>

@andreyfel
Copy link
Contributor

I encountered this error while updating ember-cached-decorator-polyfill from 0.1.4 to 1.0.1 in our app. I was able to track it down to this issue emberjs/ember-classic-decorator#99.

If you are still experiencing this issue, check if you have ember-classic-decorator in your dependencies.

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

No branches or pull requests

7 participants