From c7483b5d3a93f96e13f3491e18799506d1084016 Mon Sep 17 00:00:00 2001 From: Cassie Tarakajian Date: Tue, 8 Nov 2016 13:11:07 -0500 Subject: [PATCH] fix #190, also fix bug in which fontSize and indentation amount could be NaN --- client/modules/IDE/components/Preferences.js | 24 ++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/client/modules/IDE/components/Preferences.js b/client/modules/IDE/components/Preferences.js index d44fd05d..11b840ba 100644 --- a/client/modules/IDE/components/Preferences.js +++ b/client/modules/IDE/components/Preferences.js @@ -9,19 +9,31 @@ const exitUrl = require('../../../images/exit.svg'); const plusUrl = require('../../../images/plus.svg'); const minusUrl = require('../../../images/minus.svg'); const beepUrl = require('../../../sounds/audioAlert.mp3'); +// import { debounce } from 'lodash'; class Preferences extends React.Component { constructor(props) { super(props); this.handleUpdateAutosave = this.handleUpdateAutosave.bind(this); + this.handleUpdateFont = this.handleUpdateFont.bind(this); + this.handleUpdateIndentation = this.handleUpdateIndentation.bind(this); + this.handleLintWarning = this.handleLintWarning.bind(this); } handleUpdateFont(event) { - this.props.setFontSize(parseInt(event.target.value, 10)); + let value = parseInt(event.target.value, 10); + if (isNaN(value)) { + value = 16; + } + this.props.setFontSize(value); } handleUpdateIndentation(event) { - this.props.setIndentation(parseInt(event.target.value, 10)); + let value = parseInt(event.target.value, 10); + if (isNaN(value)) { + value = 2; + } + this.props.setIndentation(value); } handleUpdateAutosave(event) { @@ -73,6 +85,10 @@ class Preferences extends React.Component { role="status" value={this.props.fontSize} onChange={this.handleUpdateFont} + ref="fontSizeInput" + onClick={() => { + this.refs.fontSizeInput.select(); + }} >