From 17029290799731f50ede9292f94be05778cc98bb Mon Sep 17 00:00:00 2001 From: Franz Liedke Date: Thu, 8 Aug 2019 22:40:30 +0200 Subject: [PATCH] a11y: Try to make screenreaders read tooltips Refs #1835. --- framework/core/js/src/common/components/Button.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/framework/core/js/src/common/components/Button.js b/framework/core/js/src/common/components/Button.js index d9605a31c..7df7423b1 100644 --- a/framework/core/js/src/common/components/Button.js +++ b/framework/core/js/src/common/components/Button.js @@ -29,6 +29,12 @@ export default class Button extends Component { attrs.className = attrs.className || ''; attrs.type = attrs.type || 'button'; + // If a tooltip was provided for buttons without additional content, we also + // use this tooltip as text for screen readers + if (attrs.title && !this.props.children) { + attrs['aria-label'] = attrs.title; + } + // If nothing else is provided, we use the textual button content as tooltip if (!attrs.title && this.props.children) { attrs.title = extractText(this.props.children);