Skip to content

Commit

Permalink
add callback prop for onModalLabelOk
Browse files Browse the repository at this point in the history
  • Loading branch information
jansule committed Sep 20, 2018
1 parent 922ebea commit 8bd445f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/Button/DigitizeButton/DigitizeButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,13 @@ class DigitizeButton extends React.Component {
*
* @type {Function} onToggle
*/
onToggle: PropTypes.func
onToggle: PropTypes.func,

/**
* Callback function that will be called
* when the ok-button of the modal was clicked
*/
onModalLabelOk: PropTypes.func
};

/**
Expand Down Expand Up @@ -934,10 +940,21 @@ class DigitizeButton extends React.Component {
* Turns visibility of modal off and call `setTextOnFeature` method.
*/
onModalLabelOk = () => {
const {
textLabel
} = this.state;

const {
onModalLabelOk
} = this.props;

this.setState({
showLabelPrompt: false
}, () => {
this.setTextOnFeature(this._digitizeTextFeature);
if (onModalLabelOk) {
onModalLabelOk(this._digitizeTextFeature, textLabel);
}
});
}

Expand Down Expand Up @@ -1042,6 +1059,7 @@ class DigitizeButton extends React.Component {
modifyInteractionConfig,
translateInteractionConfig,
onToggle,
onModalLabelOk,
...passThroughProps
} = this.props;

Expand Down

0 comments on commit 8bd445f

Please sign in to comment.