From 07a225c161a9fda1695531c556eb730f5964d4b5 Mon Sep 17 00:00:00 2001 From: Apoorv Taneja Date: Tue, 13 Aug 2019 21:57:31 +0530 Subject: [PATCH] Fixed input field (#1130) * fixed * fixed * fixed --- client/modules/IDE/components/Preferences.jsx | 14 ++-- client/styles/components/_preferences.scss | 73 +++++++++++-------- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/client/modules/IDE/components/Preferences.jsx b/client/modules/IDE/components/Preferences.jsx index 1d3402eb..eb31ddc7 100644 --- a/client/modules/IDE/components/Preferences.jsx +++ b/client/modules/IDE/components/Preferences.jsx @@ -29,9 +29,12 @@ class Preferences extends React.Component { } onFontInputChange(event) { - this.setState({ - fontSize: event.target.value - }); + const INTEGER_REGEX = /^[0-9\b]+$/; + if (event.target.value === '' || INTEGER_REGEX.test(event.target.value)) { + this.setState({ + fontSize: event.target.value + }); + } } onFontInputSubmit(event) { @@ -151,10 +154,9 @@ class Preferences extends React.Component { aria-atomic="true" value={this.state.fontSize} onChange={this.onFontInputChange} + type="text" ref={(element) => { this.fontSizeInput = element; }} - onClick={() => { - this.fontSizeInput.select(); - }} + onClick={() => { this.fontSizeInput.select(); }} />