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
appendChild null when using modals from ember-engines #175
Comments
I have not worked with engines yet, unfortunately. The Maybe this is normal when using it in an engine, I can't tell. You could try to disable the initializer by setting let app = new EmberApp({
'ember-bootstrap': {
insertEmberWormholeElementToDom: false
}
}); Then you would have to manually add a div like shown above at the highest DOM level, so probably into the application template. Maybe this would solve it? |
Guarding against the null seems to be what works:
should I submit a PR? |
Would be welcome! |
So far the workaround above only helps with the null issue. Once the view displays, |
Do you have a |
The initializer's job is to create it, but as this is failing in your case, it should be added somewhere, otherwise the modals will be inserted into the DOM where the component is defined, which is in general not the best place (think of a parent having `overflow: hidden') |
Yes I do have the div. All of the host app's modals work. I can inspect the DOM and see the container with all my other modals. However, the modal that comes from the engine will render in place (like you mentioned above). This lead me to believe that the issue may reside in |
This might be the case. It looks up the wormhole destination element here: https://github.com/yapplabs/ember-wormhole/blob/master/addon/components/ember-wormhole.js#L28. Maybe it somehow cannot "see" the div of the host app, just a sub tree of the DOM? (just guessing, not sure how engines work in detail) But you can try with a simple single wormhole: {{#ember-wormhole to="ember-bootstrap-modal-container"}}
Hello world!
{{/ember-wormhole}} If that does not work, the underlying problem could indeed be in ember-wormhole itself! |
Drilling down even more today it seems that {{#ember-wormhole to="ember-bootstrap-modal-container"}}
Hello world!
{{/ember-wormhole}} works just about everywhere (route templates, components) but as soon as I use |
Hm, strange... The modal checks for the existence of the container element, if that is not found, falls back to "renderInPlace". This is done in a computed property here: https://github.com/kaliber5/ember-bootstrap/blob/master/addon/components/bs-modal.js#L359-L361 It might be the case that when evaluating that property for the first time, that the container does not exist yet, and afterwards the property is cached as every CP, so does not reevaluate... Does this make any difference: {{#bs-model _renderInPlace=false}}...{{/bs-modal}} |
Nada. :-(. After a bit more hacking, I finally got the stack trace to complain that the background element isn't there. Further assertions and errors led me to this error free usage {{#bs-modal title="Simple Dialog" size="sm" fade=false open=false _renderInPlace=false}}
Hi there
{{/bs-modal}} but still it renders in plain sight. I have a feeling that this is a compound issue that includes glimmer 2, engines, and ember-wormhole. I'm fairly clueless on how to attack this any further. |
@simonihmig after many days of more hacking it looks as though you have to import the layout import layout from '../templates/components/bs-modal';
export default Ember.Component.extend({
layout,
... to get the engine to wormhole the modal. I'm not too sure why the hbs for the modal lives in |
Hm, interesting, thanks for investigating! There is no real reason other than putting the templates into app was the default of ember-cli in the early days when those components were created, while the newer ones use the different setup in addon (+ importing the layout). I have refactored all of this already for the upcoming 1.0 release (see #158). But I am hesitant to change this for the current version because I am unsure if that could be a breaking change for current users which maybe rely on just overriding a compotent template by putting it into their app/templates folder. |
No worries! I have forked this addon and patched what was needed to stay compatible with my app. I'd be happy to test drive the 1.0 release and see if meets my needs. Let me know if you are interested in any PR's from my fork but otherwise I think we can close the issue. |
OK. So by explicitly importing the layout into If that is all it took, then I would not need a PR as this has already been done for the 1.0 branch as I said. But thanks anyway! |
Ok! Btw the initializer is still an issue and the guard I mention earlier in the thread is viable but it has the issue of not being able to get the app context from the engine. I may look into this and submit real fix once I find one. Thank you! |
When using modals from an engine, the engine routes produces this error if
{{bs-modal}}
is used:The host app has no issues. Ember 2.10, Ember-engines 0.4.0
The text was updated successfully, but these errors were encountered: