WIP: feature(dialog): add ability to open dialog with portal #2851
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I haven't really created this with hope of it being merged, but rather to get some feedback. There are some unused imports, couple of missing comments, no tests, I'll fix all of those if you tell me if this direction is fine.
I tried to make opening just by using
TemplateRef
work, but I couldn't quite figure out which would be the properviewContainerRef
to use, there's still no easy way to get root component'sviewContainerRef
, right? I think it could probably useMdDialogContainer
,viewContainerRef
, so I could change it to that if you say it's a good idea(here's a branch with that https://github.com/fxck/material2/tree/dialog-templateref)MdDialog
,MdDialogRef
and various methods require generics of a component, should it still be required when using templateRef/portal? You don't need to exposecomponentInstance
when using templateRef, you can simply use standard inputs.. how should this be reflected?I needed to expose backdropClick event(to be able to make truly stateless components, will explain later), is the way I'e done it ok(apart from
$
suffix which I think you don't really use)I wanted to reuse
_attachDialogContent
, tried couple of things, but the only viable way ended up being adding ability to pass in either component or portal(https://github.com/fxck/material2/blob/15313f94ae75b6464054ada0bbad353eb1c9a0f8/src/lib/dialog/dialog.ts#L168-L169), I don't like it, but since it's a private, internal method, it shouldn't really be that bad, right?I've added
md-dialog
component, which is a component with api following that of https://developer.mozilla.org/en/docs/Web/HTML/Element/dialog I know you are not fan of that, so it just temporar to test my usecase for opening dialog with templateRef/portal, and I encountered one problem, and that isit happens when I try to open the dialog inside
@Input
setter, I thinklet overlayRef = this._createOverlay(config);
is what's causing it.. it was fixed by usingsetTimeout
, which would be "fine" if it was internal(I assume somezone
function instead ofsetTimeout
would work as well), but you can't expect that from the consumer.. so I could use some help fixing itanyway the idea behind the
md-dialog
component, should you decode it's something you'd want in the repo, is that it's completely stateless by default, which means the consumer is in full control of the state, backdrop / esc key should not close it, they should expose and event that close attempt happened and let the user decide what to do with the state instead.. it's something you totally need when using state manager like https://github.com/ngrx/store I think this behaviour should be by default, but I think it could use another input with config(MdDialogConfig
), where one could turndisableClose
back on@jelbourn @crisbeto @devversion maybe?