Skip to content

Commit

Permalink
feat(ui5-dialog): improve accessibility (#1288)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed Mar 12, 2020
1 parent 0746012 commit ef2886b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/main/src/Dialog.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<span class="ui5-popup-frame" @focusin="{{_onfocusin}}">
<span id="{{_id}}-firstfe" tabindex="0"></span>
<div style="{{zindex}}" class="ui5-dialog-root-parent {{classes.dialogParent}}">
<div tabindex="-1" aria-labelledby="{{headerId}}" role="dialog" aria-modal="true" class="ui5-popup-root ui5-dialog-root {{classes.dialogParent}}">
<div tabindex="-1" aria-labelledby="{{headerAriaLabelledBy}}" role="dialog" aria-modal="true" class="ui5-popup-root ui5-dialog-root {{classes.dialogParent}}">
{{> header}}
<section class="ui5-dialog-section">
<div class="ui5-popup-content">
Expand Down
7 changes: 7 additions & 0 deletions packages/main/src/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class Dialog extends Popup {
get blockLayer() {
return `z-index: ${this._zIndex};`;
}

get headerAriaLabelledBy() {
if (this.headerText || this.header) {
return `${this._id}-popup-heading`;
}
return undefined;
}
}

Dialog.define();
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/Popup.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
{{#if hasHeader}}
<header>
{{#if header.length}}
<div role="{{role}}" class="ui5-popup-header">
<div id="{{_id}}-popup-heading" role="{{role}}" class="ui5-popup-header">
<slot name="header"></slot>
</div>
{{else}}
<h2 role="{{role}}" class="ui5-popup-header ui5-popup-headerText">{{headerText}}</h2>
<h2 id="{{_id}}-popup-heading" role="{{role}}" class="ui5-popup-header ui5-popup-headerText">{{headerText}}</h2>
{{/if}}
</header>
{{/if}}
Expand Down

0 comments on commit ef2886b

Please sign in to comment.