fix(client): remove didUpdate on a learn's side-panel

This commit is contained in:
Valeriy S
2019-01-23 10:56:21 +03:00
committed by Stuart Taylor
parent 1f4fa29860
commit 18a42f37cd
2 changed files with 12 additions and 33 deletions

View File

@ -1,6 +1,5 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ReactDom from 'react-dom';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { bindActionCreators } from 'redux'; import { bindActionCreators } from 'redux';
@ -41,11 +40,6 @@ const propTypes = {
}; };
export class SidePanel extends Component { export class SidePanel extends Component {
constructor(props) {
super(props);
this.bindTopDiv = this.bindTopDiv.bind(this);
}
componentDidMount() { componentDidMount() {
MathJax.Hub.Config({ MathJax.Hub.Config({
tex2jax: { tex2jax: {
@ -62,26 +56,6 @@ export class SidePanel extends Component {
this.props.initConsole(''); this.props.initConsole('');
} }
componentDidUpdate(prevProps) {
MathJax.Hub.Queue([
'Typeset',
MathJax.Hub,
document.querySelector('.rosetta-code')
]);
const { title, initConsole } = this.props;
if (title !== prevProps.title) {
initConsole('');
const node = ReactDom.findDOMNode(this.descriptionTop);
setTimeout(() => {
node.scrollIntoView({ behavior: 'smooth' });
}, 0);
}
}
bindTopDiv(node) {
this.descriptionTop = node;
}
render() { render() {
const { const {
title, title,
@ -95,15 +69,16 @@ export class SidePanel extends Component {
} = this.props; } = this.props;
return ( return (
<div className='instructions-panel' role='complementary'> <div className='instructions-panel' role='complementary'>
<div ref={this.bindTopDiv} />
<Spacer /> <Spacer />
<div> <div>
<ChallengeTitle>{title}</ChallengeTitle> <ChallengeTitle>{title}</ChallengeTitle>
<ChallengeDescription description={description} instructions={instructions} section={section} /> <ChallengeDescription
description={description}
instructions={instructions}
section={section}
/>
</div> </div>
{ showToolPanel && ( {showToolPanel && <ToolPanel guideUrl={guideUrl} videoUrl={videoUrl} />}
<ToolPanel guideUrl={guideUrl} videoUrl={videoUrl} />
)}
<TestSuite tests={tests} /> <TestSuite tests={tests} />
</div> </div>
); );
@ -113,4 +88,7 @@ export class SidePanel extends Component {
SidePanel.displayName = 'SidePanel'; SidePanel.displayName = 'SidePanel';
SidePanel.propTypes = propTypes; SidePanel.propTypes = propTypes;
export default connect(mapStateToProps, mapDispatchToProps)(SidePanel); export default connect(
mapStateToProps,
mapDispatchToProps
)(SidePanel);

View File

@ -3,4 +3,5 @@
.MathJax_Display { .MathJax_Display {
max-width: 100%; max-width: 100%;
overflow-x: auto; overflow-x: auto;
} overflow-y: hidden;
}