From 9960e86508ce887a6b7ed05cbd35102c26710eb0 Mon Sep 17 00:00:00 2001 From: sethk Date: Tue, 19 Apr 2016 16:19:30 -0500 Subject: [PATCH] Removed automated aria-labelledby features as they aren't needed to ensure accessibility Added documentation to explain how to utilize aria-labelledby --- docs/pages/reveal.md | 19 +++++++++++++++++++ js/foundation.reveal.js | 32 +++++++++++--------------------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/docs/pages/reveal.md b/docs/pages/reveal.md index aa9db1de4..68572f489 100644 --- a/docs/pages/reveal.md +++ b/docs/pages/reveal.md @@ -186,3 +186,22 @@ $.ajax('/url') $modal.html(resp.html).foundation('open'); }); ``` + + +--- + +## Accessibility + +Modals by default are accessible through the use of various ARIA attributes. To make a modal even more accessible, designate a label to the modal by adding `aria-labelledby="exampleModalHeader11"` to the container and `id="exampleModalHeader11"` to the elment you want to designate as the label. + +```html_example +

Click me for a modal

+ +
+

Label for the Modal!

+

I am even more accessible than the other modals.

+ +
+``` diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index 1842878eb..62205a54a 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -47,32 +47,12 @@ class Reveal { if(this.isiOS){ this.$element.addClass('is-ios'); } this.$anchor = $(`[data-open="${this.id}"]`).length ? $(`[data-open="${this.id}"]`) : $(`[data-toggle="${this.id}"]`); - // Accessibility Update: An element that envokes a modal should have a tabindex of zero and aria tags this.$anchor.attr({ 'aria-controls': this.id, 'aria-haspopup': true, 'tabindex': 0 }); - // Accessibility Update : Conditional to determine which elements provides the aria-labeledby content. - // If there is a header associate the aria-labeledby to the header vs. the link - this.$header = $(this.$element.find('h1,h2,h3,h4,h5,h6')[0]); - if( this.$header.length ){ - var headerId = this.$header[0].id || Foundation.GetYoDigits(6, 'reveal'); - this.$header.attr({ - 'id': headerId - }); - this.$element.attr({'aria-labelledby': headerId}); - - // If no header associate the link text to the aria-labeledby - } else if (this.$anchor.length) { - var anchorId = this.$anchor[0].id || Foundation.GetYoDigits(6, 'reveal'); - this.$anchor.attr({ - 'id': anchorId, - }); - this.$element.attr({'aria-labelledby': anchorId}); - } - if (this.options.fullScreen || this.$element.hasClass('full')) { this.options.fullScreen = true; this.options.overlay = false; @@ -240,14 +220,24 @@ class Reveal { */ this.$element.trigger('closeme.zf.reveal', this.id); } - // Motion UI method of reveal if (this.options.animationIn) { + var _this = this; + function afterAnimationFocus(){ + _this.$element + .attr({ + 'aria-hidden': false, + 'tabindex': -1 + }) + .focus(); + console.log('focus'); + } if (this.options.overlay) { Foundation.Motion.animateIn(this.$overlay, 'fade-in'); } Foundation.Motion.animateIn(this.$element, this.options.animationIn, () => { this.focusableElements = Foundation.Keyboard.findFocusable(this.$element); + afterAnimationFocus(); }); } // jQuery method of reveal -- 2.47.2