Skip to content

Commit

Permalink
Merge pull request #372 from Yoast/stories/add-content-analysis-butto…
Browse files Browse the repository at this point in the history
…n-callback

Add ContentAnalysis mark button callback
  • Loading branch information
IreneStr authored Nov 6, 2017
2 parents 19e70f7 + e600535 commit 8a7e942
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ class ContentAnalysis extends React.Component {
* Handles button clicks. Makes sure no more than one button can be active at the same time.
*
* @param {string} id The button id.
* @param {Object} marker TinyMCE marker object.
*
* @returns {void}
*/
handleClick( id ) {
handleClick( id, marker ) {
if ( id === this.state.checked ) {
this.setState( {
checked: "",
Expand All @@ -97,6 +98,8 @@ class ContentAnalysis extends React.Component {
this.setState( {
checked: id,
} );

this.props.onMarkButtonClick( id, marker );
}

/**
Expand Down Expand Up @@ -137,7 +140,7 @@ class ContentAnalysis extends React.Component {
ariaLabel={ this.props.intl.formatMessage( messages.highlight ) }
pressed={ result.id === this.state.checked }
buttonId={ result.id }
onButtonClick={ this.handleClick.bind( this, result.id ) }
onButtonClick={ this.handleClick.bind( this, result.id, result.marker ) }
/>;
} );
}
Expand Down Expand Up @@ -215,6 +218,7 @@ class ContentAnalysis extends React.Component {
}

ContentAnalysis.propTypes = {
onMarkButtonClick: PropTypes.func,
problemsResults: PropTypes.array,
improvementsResults: PropTypes.array,
goodResults: PropTypes.array,
Expand All @@ -227,6 +231,7 @@ ContentAnalysis.propTypes = {
};

ContentAnalysis.defaultProps = {
onMarkButtonClick: () => {},
problemsResults: [],
improvementsResults: [],
goodResults: [],
Expand Down

0 comments on commit 8a7e942

Please sign in to comment.