From 422ab81185433c3d61cd261760dfcaee192b72e2 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 25 Nov 2019 12:31:57 +0100 Subject: [PATCH 1/2] a11y adjustments for toasts --- src/components/structures/ToastContainer.js | 2 +- src/components/views/toasts/VerificationRequestToast.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/structures/ToastContainer.js b/src/components/structures/ToastContainer.js index b8ced1e9de..83bbdac1a1 100644 --- a/src/components/structures/ToastContainer.js +++ b/src/components/structures/ToastContainer.js @@ -74,7 +74,7 @@ export default class ToastContainer extends React.Component { }); return ( -
+

{title}{countIndicator}

{React.createElement(component, toastProps)}
diff --git a/src/components/views/toasts/VerificationRequestToast.js b/src/components/views/toasts/VerificationRequestToast.js index c6f7f3a363..89af91c41f 100644 --- a/src/components/views/toasts/VerificationRequestToast.js +++ b/src/components/views/toasts/VerificationRequestToast.js @@ -108,7 +108,7 @@ export default class VerificationRequestToast extends React.PureComponent { } return (
{nameLabel}
-
+
From 694f2cb1dc676c06fd2961e566eeaf144c5cf603 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 25 Nov 2019 13:20:20 +0100 Subject: [PATCH 2/2] make sure the toast container is always in the document --- src/components/structures/ToastContainer.js | 43 ++++++++++----------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/components/structures/ToastContainer.js b/src/components/structures/ToastContainer.js index 83bbdac1a1..a8dca35747 100644 --- a/src/components/structures/ToastContainer.js +++ b/src/components/structures/ToastContainer.js @@ -50,35 +50,34 @@ export default class ToastContainer extends React.Component { render() { const totalCount = this.state.toasts.length; - if (totalCount === 0) { - return null; - } const isStacked = totalCount > 1; - const topToast = this.state.toasts[0]; - const {title, icon, key, component, props} = topToast; + let toast; + if (totalCount !== 0) { + const topToast = this.state.toasts[0]; + const {title, icon, key, component, props} = topToast; + const toastClasses = classNames("mx_Toast_toast", { + "mx_Toast_hasIcon": icon, + [`mx_Toast_icon_${icon}`]: icon, + }); + const countIndicator = isStacked ? _t(" (1/%(totalCount)s)", {totalCount}) : null; + + const toastProps = Object.assign({}, props, { + dismiss: this.dismissTopToast, + key, + }); + toast = (
+

{title}{countIndicator}

+
{React.createElement(component, toastProps)}
+
); + } const containerClasses = classNames("mx_ToastContainer", { "mx_ToastContainer_stacked": isStacked, }); - const toastClasses = classNames("mx_Toast_toast", { - "mx_Toast_hasIcon": icon, - [`mx_Toast_icon_${icon}`]: icon, - }); - - const countIndicator = isStacked ? _t(" (1/%(totalCount)s)", {totalCount}) : null; - - const toastProps = Object.assign({}, props, { - dismiss: this.dismissTopToast, - key, - }); - return ( -
-
-

{title}{countIndicator}

-
{React.createElement(component, toastProps)}
-
+
+ {toast}
); }