diff --git a/src/components/menu/ModeMenu.js b/src/components/menu/ModeMenu.js index 5012be5..a6db527 100644 --- a/src/components/menu/ModeMenu.js +++ b/src/components/menu/ModeMenu.js @@ -16,7 +16,15 @@ export default class ModeMenu extends Component { title: `Switch to ${mode} mode`, className: 'jsoneditor-menu-button jsoneditor-type-modes' + ((mode === this.props.mode) ? ' jsoneditor-selected' : ''), - onClick: this.handleClick + onClick: () => { + try { + this.props.onRequestClose() + this.props.onChangeMode(mode) + } + catch (err) { + this.props.onError(err) + } + } }, toCapital(mode)) }) @@ -29,16 +37,6 @@ export default class ModeMenu extends Component { } } - handleClick = () => { - try { - this.props.onRequestClose() - this.props.onChangeMode(mode) - } - catch (err) { - this.props.onError(err) - } - } - componentDidMount () { this.updateRequestCloseListener() }