-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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(dialog): add result to MdDialogClose directive #4332
feat(dialog): add result to MdDialogClose directive #4332
Conversation
result
to MdDialogClose directiveThere 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.
Looks good, just needs a mention in the docs
@@ -17,6 +17,9 @@ export class MdDialogClose { | |||
/** Screenreader label for the button. */ | |||
@Input('aria-label') ariaLabel: string = 'Close dialog'; | |||
|
|||
/** Result to return to the dialog opener. */ | |||
@Input('md-dialog-close') result: any; |
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.
Can you also update the overview in dialog.md
to mention this feature?
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.
@jelbourn I've done it! The tests below failed but the errors are not related to this commit.
What should I do?
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 doesn't work in compatibility mode. We need something for mat-dialog-close
too.
e56b469
to
66166c4
Compare
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.
Just a couple comments on the docs
src/lib/dialog/dialog.md
Outdated
<md-dialog-actions> | ||
<button md-button [md-dialog-close]="true">Yes</button> | ||
<button md-button [md-dialog-close]="false">No</button> | ||
</md-dialog-actions> |
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.
One example should show the button without the value and one with, e.g.:
<h2 md-dialog-title>Delete all</h2>
<md-dialog-content>Are you sure?</md-dialog-content>
<md-dialog-actions>
<button md-button md-dialog-close>Yes</button>
<!-- Can optionally provide a result for the closing dialog. -->
<button md-button [md-dialog-close]="false">No</button>
</md-dialog-actions>
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.
👍
src/lib/dialog/dialog.md
Outdated
| `md-dialog-title` | \[Attr] Dialog title, applied to a heading element (e.g., `<h1>`, `<h2>`) | | ||
| `<md-dialog-content>` | Primary scrollable content of the dialog | | ||
| `<md-dialog-actions>` | Container for action buttons at the bottom of the dialog | | ||
| `md-dialog-close` | \[Attr] Added to a `<button>`, makes the button close the dialog and return the binded value on click| |
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.
\[Attr] Added to a `<button>`, makes the button close the dialog with an optional result from the bound value.
66166c4
to
0643a2e
Compare
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
83d193f
to
b8365a8
Compare
@devversion I've added |
/** Result for compatibility mode */ | ||
@Input('mat-dialog-close') | ||
get _matResult(): any { return this.result; } | ||
set _matResult(r: any) { this.result = r; } |
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.
I think we can also have just the set
here
/** Dialog close input for compatibility mode. */
@Input('mat-dialog-close') set _matDialogClose(value: any) { this.dialogResult = value; }
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.
@devversion You are right. I've changed that.
e1de055
to
de86e14
Compare
MdDialog has MdDialogClose to make it easier to structure a dialog. But as MdDialogClose doesn't return any value, it's imposibble to use MdDialogClose if you want to get any return value when MdDialog is close. So `@Input('md-dialog-close')result` is added to MdDialogClose to solve it. no breaking changes
de86e14
to
b85fa23
Compare
@devversion Any updates? |
@nallwhy Sorry I forgot about it. It's now merge ready and should be merged soon! Thanks again |
@devversion Thanks! |
Note that this changed the default value from
I ran into this issue when upgrading angular/material2. The fix was trivial:
Just leaving this here for others to see. |
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. |
MdDialog has MdDialogClose to make it easier to structure a dialog.
But as MdDialogClose doesn't return any value, it's imposibble to use MdDialogClose if you want to get any return value when MdDialog is closed.
So
@Input('md-dialog-close')result
is added to MdDialogClose to solve it.no breaking changes