-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat(modal): allow interactions with components passed as content #903
feat(modal): allow interactions with components passed as content #903
Conversation
I have some questions regarding this design:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This is the biggest issue with dynamically created components, in general. IMO we can add or remove
TBH it is beyond my current TS knowledge. Feel free to build on top of this PR to add type safety. |
That's my biggest fear with this design: I fear that people use components not intended to be used in a modal originally, and then complain to us because the component uses standard lifecycle callbacks on inputs and they don't work as usual. But you're in a better position than I am to choose the right solution.
I'll try doing that when I have some time. But I'm not sure it's even possible. |
That's the danger, I agree. But given that there are no great solutions I prefer to err on the flexibility side.
Thnx for the trust, but I don't think we are in the position of choosing "right" solution. The way I feel about it is that we are just balancing different tradeoffs. I'm planning to take this issue with Misko and Material folks but at the same time don't want to block people from using modals. Event if the solution proposed here isn't perfect it is simple, flexible and we are still in alpha so nothing is set in stone. Let's get some real-World feedback. |
@@ -29,13 +31,23 @@ export class NgbModalRef { | |||
private _reject: (reason?: any) => void; | |||
|
|||
/** | |||
* The instance of component used as modal's content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This property doesn't appear in the generated doc in the demo.
Regarding generic open() and NgbModalRef, here's an implementation: jnizet@75aa2b6 Advantages:
|
So, after long and painful deliberations I'm going to make an "executive decision" and merge this one as-is. Being painfully aware of all the imperfections of this PR I believe that this is a good compromise for now. Let's iterate on it. |
@pkozlowski-opensource You were looking for real-world feedback, so here is some. As you say, this approach is quite flexible, but I've run into some of the issues raised above. I'm showing a form in a modal that I am building from data that has to be passed to the modal. I was passing the data in as an But at least I'm able to use the modal for my use case, so that is a plus. |
@karptonite I'm in a similar situation, and came to the same solution of writing a manual initialization function. @pkozlowski-opensource I understand this is a limitation of Angular, so I don't think there's a better solution at the moment, but I think this would benefit from being spelled out explicitly in the documentation. Perhaps a brief warning that change detection in modal components is different from other components, similar to the warning about entryComponents? I had to read through a few Github issues before I realized what was going on. |
Closes #861