Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #120 from PolymerElements/no-iron-announce
Browse files Browse the repository at this point in the history
Adds a `noIronAnnounce` property.
  • Loading branch information
bicknellr authored Jan 7, 2021
2 parents 08390d9 + 4ffeb19 commit 048a710
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
14 changes: 12 additions & 2 deletions paper-toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,15 @@ Polymer({
* Set to true to disable auto-focusing the toast or child nodes with
* the `autofocus` attribute` when the overlay is opened.
*/
noAutoFocus: {type: Boolean, value: true}
noAutoFocus: {type: Boolean, value: true},

/**
* Set to true to prevent paper-toast from dispatching 'iron-announce'
* events. (`<iron-a11y-announcer>` updates an `aria-live` region in
* response to these events, causing the region to be automatically read by
* screen readers.)
*/
noIronAnnounce: {type: Boolean, value: false},
},

listeners: {'transitionend': '__onTransitionEnd'},
Expand Down Expand Up @@ -254,7 +262,9 @@ Polymer({
currentToast.close();
}
currentToast = this;
this.fire('iron-announce', {text: this.text});
if (!this.noIronAnnounce) {
this.fire('iron-announce', {text: this.text});
}
if (this._canAutoClose) {
this._autoClose = this.async(this.close, this.duration);
}
Expand Down
9 changes: 9 additions & 0 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@
'text announced');
});

test('show() will not announce text if noIronAnnounce is set', function() {
toast = fixture('basic');
toast.noIronAnnounce = true;
var spy = sinon.spy(toast, 'fire');
toast.text = 'announce!';
toast.show();
assert.isFalse(spy.called, 'text announced');
});

test('hide() will not announce text', function() {
toast = fixture('show');
var spy = sinon.spy(toast, 'fire');
Expand Down

0 comments on commit 048a710

Please sign in to comment.