-
Notifications
You must be signed in to change notification settings - Fork 6.8k
demo(dialog): Add accessibility demo page for dialog #6360
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<section> | ||
<h2>Welcome message</h2> | ||
<p>Activate the button to see a welcome dialog with a simple message and a close button.</p> | ||
<button md-button (click)="openWelcomeDialog()">Welcome</button> | ||
</section> | ||
|
||
<section> | ||
<h2>Choose a fruit</h2> | ||
<p>Active the button to choose apple or peach in a dialog.</p> | ||
<button md-button (click)="openFruitDialog()">Fruit</button> | ||
<p *ngIf="fruitSelectedOption"> | ||
You chose: {{fruitSelectedOption}} | ||
</p> | ||
</section> | ||
|
||
<section> | ||
<h2>Neptune</h2> | ||
<p> | ||
Active the button to see a dialog showing information of Neptune. | ||
A Uncyclopedia page can be opened either in a new tab or in a stacked dialog. | ||
</p> | ||
<button md-button (click)="openNeptuneDialog()">Learn Neptune</button> | ||
</section> | ||
|
||
<section> | ||
<h2>Address form</h2> | ||
<p> | ||
Active the button to fill out shipping address information in a dialog. | ||
</p> | ||
<button md-button (click)="openAddressDialog()">Add address</button> | ||
</section> |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import {Component} from '@angular/core'; | ||
import {MdDialog} from '@angular/material'; | ||
|
||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dialog-a11y', | ||
templateUrl: 'dialog-a11y.html', | ||
styleUrls: ['dialog-a11y.css'], | ||
}) | ||
export class DialogAccessibilityDemo { | ||
fruitSelectedOption: string = ''; | ||
|
||
constructor(public dialog: MdDialog) {} | ||
|
||
openFruitDialog() { | ||
let dialogRef = this.dialog.open(DialogFruitExampleDialog); | ||
dialogRef.afterClosed().subscribe(result => { | ||
this.fruitSelectedOption = result; | ||
}); | ||
} | ||
|
||
openWelcomeDialog() { | ||
this.dialog.open(DialogWelcomeExampleDialog); | ||
} | ||
|
||
openNeptuneDialog() { | ||
this.dialog.open(DialogNeptuneExampleDialog); | ||
} | ||
|
||
openAddressDialog() { | ||
this.dialog.open(DialogAddressFormDialog); | ||
} | ||
} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dialog-fruit-a11y', | ||
templateUrl: 'dialog-fruit-a11y.html' | ||
}) | ||
export class DialogFruitExampleDialog {} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dialog-welcome-a11y', | ||
templateUrl: 'dialog-welcome-a11y.html' | ||
}) | ||
export class DialogWelcomeExampleDialog {} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dialog-neptune-a11y-dialog', | ||
templateUrl: './dialog-neptune-a11y.html' | ||
}) | ||
export class DialogNeptuneExampleDialog { | ||
constructor(public dialog: MdDialog) { } | ||
|
||
showInStackedDialog() { | ||
this.dialog.open(DialogNeptuneIFrameDialog); | ||
} | ||
} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dialog-neptune-iframe-dialog', | ||
styles: [ | ||
`iframe { | ||
width: 800px; | ||
}` | ||
], | ||
templateUrl: './dialog-neptune-iframe-a11y.html' | ||
}) | ||
export class DialogNeptuneIFrameDialog {} | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'dialog-address-form-a11y', | ||
templateUrl: 'dialog-address-form-a11y.html' | ||
}) | ||
export class DialogAddressFormDialog {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<h2 md-dialog-title>Company</h2> | ||
|
||
<md-dialog-content> | ||
<form class="example-form"> | ||
<md-form-field class="example-full-width"> | ||
<input mdInput placeholder="Company (disabled)" disabled value="Google"> | ||
</md-form-field> | ||
|
||
<table class="example-full-width" cellspacing="0"><tr> | ||
<td><md-form-field class="example-full-width"> | ||
<input mdInput placeholder="First name"> | ||
</md-form-field></td> | ||
<td><md-form-field class="example-full-width"> | ||
<input mdInput placeholder="Long Last Name That Will Be Truncated"> | ||
</md-form-field></td> | ||
</tr></table> | ||
|
||
<p> | ||
<md-form-field class="example-full-width"> | ||
<textarea mdInput placeholder="Address">1600 Amphitheatre Pkwy</textarea> | ||
</md-form-field> | ||
<md-form-field class="example-full-width"> | ||
<textarea mdInput placeholder="Address 2"></textarea> | ||
</md-form-field> | ||
</p> | ||
|
||
<table class="example-full-width" cellspacing="0"><tr> | ||
<td><md-form-field class="example-full-width"> | ||
<input mdInput placeholder="City"> | ||
</md-form-field></td> | ||
<td><md-form-field class="example-full-width"> | ||
<input mdInput placeholder="State"> | ||
</md-form-field></td> | ||
<td><md-form-field class="example-full-width"> | ||
<input mdInput #postalCode maxlength="5" placeholder="Postal Code" value="94043"> | ||
<md-hint align="end">{{postalCode.value.length}} / 5</md-hint> | ||
</md-form-field></td> | ||
</tr></table> | ||
</form> | ||
</md-dialog-content> | ||
|
||
<md-dialog-actions> | ||
<button md-raised-button color="primary" md-dialog-close>Submit</button> | ||
<button md-raised-button md-dialog-close>Close</button> | ||
</md-dialog-actions> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h2 md-dialog-title>Fruit</h2> | ||
<div md-dialog-content>Which would you like to choose?</div> | ||
<div md-dialog-actions> | ||
<button md-button md-dialog-close="apple" aria-label="Apple">Apple</button> | ||
<button md-button md-dialog-close="peach" aria-label="Peach">Peach</button> | ||
</div> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<h2 md-dialog-title>Neptune</h2> | ||
|
||
<md-dialog-content> | ||
<img src="https://upload.wikimedia.org/wikipedia/commons/5/56/Neptune_Full.jpg" | ||
alt="Neptune"/> | ||
|
||
<p> | ||
Neptune is the eighth and farthest known planet from the Sun in the Solar System. In the | ||
Solar System, it is the fourth-largest planet by diameter, the third-most-massive planet, | ||
and the densest giant planet. Neptune is 17 times the mass of Earth and is slightly more | ||
massive than its near-twin Uranus, which is 15 times the mass of Earth and slightly larger | ||
than Neptune. Neptune orbits the Sun once every 164.8 years at an average distance of 30.1 | ||
astronomical units (4.50×109 km). It is named after the Roman god of the sea and has the | ||
astronomical symbol ♆, a stylised version of the god Neptune's trident. | ||
</p> | ||
</md-dialog-content> | ||
|
||
<md-dialog-actions> | ||
<button md-raised-button color="primary" md-dialog-close>Close</button> | ||
|
||
<a md-button color="primary" href="https://en.wikipedia.org/wiki/Neptune" target="_blank"> | ||
Read more on Uncyclopedia | ||
</a> | ||
|
||
<button md-button color="secondary" (click)="showInStackedDialog()"> | ||
Show in dialog</button> | ||
</md-dialog-actions> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h2 md-dialog-title>Neptune</h2> | ||
|
||
<md-dialog-content> | ||
<iframe frameborder="0" src="https://en.wikipedia.org/wiki/Neptune"></iframe> | ||
</md-dialog-content> | ||
|
||
<md-dialog-actions> | ||
<button md-raised-button color="primary" md-dialog-close>Close</button> | ||
</md-dialog-actions> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<h2>Welcome to Angular Material dialog demo page!</h2> | ||
|
||
<p> | ||
The Web is fundamentally designed to work for all people, whatever their hardware, software, | ||
language, culture, location, or physical or mental ability. When the Web meets this goal, it is | ||
accessible to people with a diverse range of hearing, movement, sight, and cognitive ability. | ||
</p> | ||
<p> | ||
The mission of the Web Accessibility Initiative (WAI) is to lead the Web to its full potential to | ||
be accessible, enabling people with disabilities to participate equally on the Web. | ||
</p> | ||
|
||
<button md-button color="primary" md-dialog-close>Close</button> |
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
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
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.
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.
Where does the focus go when this dialog is opened?
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.
The "Close" button in the dialog.
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 suspect that having the focus start after all of the dialog content is weird
@tinayuangao @crisbeto what do you think of adding a dialog config option like
focusDialogElementOnOpen
(and alsoariaLabel
) to help with dialogs like this?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.
It does make sense, although specifying what element takes precedence in the focus trap should already be possible through the
cdk-focus-initial
attribute.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.
That doesn't give a way to focus the
role="dialog"
element, though, which I think is what we'd want (but I'm not 100% sure).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.
Adding a config option makes sense to me.
I added another example for forms. The focus goes to the first input box in the form when the dialog is opened.