From 20c485d85e4deaae0a8090496241133902a76486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20V=C3=A1gner?= Date: Wed, 20 Dec 2017 10:09:26 +0100 Subject: [PATCH] Move aria-hidden management from the BaseDialog component to the Modal --- src/Modal.js | 14 ++++++++++++++ src/components/views/dialogs/BaseDialog.js | 18 ------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/Modal.js b/src/Modal.js index 68d75d1ff1..69ff806045 100644 --- a/src/Modal.js +++ b/src/Modal.js @@ -186,11 +186,25 @@ class ModalManager { } _reRender() { + // Retrieve the root node of the Riot application outside the modal + let applicationNode = document.getElementById('matrixchat'); if (this._modals.length == 0) { + if (applicationNode) { + // If there is no modal to render, make all of Riot available + // to screen reader users again + applicationNode.setAttribute('aria-hidden', 'false'); + } ReactDOM.unmountComponentAtNode(this.getOrCreateContainer()); return; } + if (applicationNode) { + // Hide the content outside the modal to screen reader users + // so they won't be able to navigate into it and act on it using + // screen reader specific features + applicationNode.setAttribute('aria-hidden', 'true'); + } + const modal = this._modals[0]; const dialog = (
diff --git a/src/components/views/dialogs/BaseDialog.js b/src/components/views/dialogs/BaseDialog.js index db8e530fa0..7fb642b560 100644 --- a/src/components/views/dialogs/BaseDialog.js +++ b/src/components/views/dialogs/BaseDialog.js @@ -49,24 +49,6 @@ export default React.createClass({ contentId: React.PropTypes.string, }, - componentDidMount: function() { - // Retrieve the root node of the Riot application outside the dialog - this.applicationNode = document.getElementById('matrixchat'); - if (this.applicationNode) { - // Hide the content outside the dialog to screen reader users - // so they won't be able to navigate into it and act on it using - // screen reader specific features - this.applicationNode.setAttribute('aria-hidden', 'true'); - } - }, - - componentWillUnmount: function() { - if (this.applicationNode) { - // When dismissing the dialog, make all of Riot available to screen reader users again - this.applicationNode.setAttribute('aria-hidden', 'false'); - } - }, - _onKeyDown: function(e) { if (e.keyCode === KeyCode.ESCAPE) { e.stopPropagation();