p5.js-web-editor/client/modules/IDE/components/TextOutput.jsx
Mathura MG 8e688a6103 Fix focus switch to accessible text output (#318)
* Change accessibility example links

* ensure we focus on text output
2017-03-06 15:58:36 -05:00

57 lines
1.4 KiB
JavaScript

import React, { PropTypes } from 'react';
class TextOutput extends React.Component {
componentDidMount() {
this.canvasTextOutput.focus();
}
componentDidUpdate(prevProps) {
// if the user explicitly clicks on the play button, want to refocus on the text output
if (this.props.isPlaying && this.props.previewIsRefreshing) {
this.canvasTextOutput.focus();
}
}
render() {
return (
<section
className="text-output"
id="canvas-sub"
ref={(element) => { this.canvasTextOutput = element; }}
tabIndex="0"
aria-label="text-output"
title="canvas text output"
>
<h2> Output </h2>
<section id="textOutput-content">
</section>
<p
tabIndex="0"
role="main"
id="textOutput-content-summary"
aria-label="text output summary"
>
</p>
<table
tabIndex="0"
role="main"
id="textOutput-content-table"
aria-label="text output details"
>
</table>
<div
tabIndex="0"
role="main"
id="textOutput-content-details"
aria-label="text output details"
>
</div>
</section>
);
}
}
TextOutput.propTypes = {
isPlaying: PropTypes.bool.isRequired,
previewIsRefreshing: PropTypes.bool.isRequired
};
export default TextOutput;