WIP: feature(dialog): add ability to open dialog with portal #2851
Closed
fxck wants to merge 1 commit into
Closed
Conversation
Contributor
Author
|
I'm going to split it into more PRs. |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
TemplateRefwork, but I couldn't quite figure out which would be the properviewContainerRefto 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,MdDialogRefand various methods require generics of a component, should it still be required when using templateRef/portal? You don't need to exposecomponentInstancewhen 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-dialogcomponent, 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
@Inputsetter, 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 somezonefunction instead ofsetTimeoutwould 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-dialogcomponent, 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 turndisableCloseback on@jelbourn @crisbeto @devversion maybe?