@@ -43,7 +43,12 @@ export class EditableInput extends (PureComponent || Component) {
4343 }
4444
4545 handleKeyDown = ( e ) => {
46- const number = Number ( e . target . value )
46+ // In case `e.target.value` is a percentage remove the `%` character
47+ // and update accordingly with a percentage
48+ // https://github.com/casesandberg/react-color/issues/383
49+ const stringValue = String ( e . target . value )
50+ const isPercentage = stringValue . indexOf ( '%' ) > - 1
51+ const number = Number ( stringValue . replace ( / % / g, '' ) )
4752 if ( ! isNaN ( number ) ) {
4853 const amount = this . props . arrowOffset || 1
4954
@@ -55,7 +60,11 @@ export class EditableInput extends (PureComponent || Component) {
5560 this . props . onChange && this . props . onChange ( number + amount , e )
5661 }
5762
58- this . setState ( { value : number + amount } )
63+ if ( isPercentage ) {
64+ this . setState ( { value : `${ number + amount } %` } )
65+ } else {
66+ this . setState ( { value : number + amount } )
67+ }
5968 }
6069
6170 // Down
@@ -66,7 +75,11 @@ export class EditableInput extends (PureComponent || Component) {
6675 this . props . onChange && this . props . onChange ( number - amount , e )
6776 }
6877
69- this . setState ( { value : number - amount } )
78+ if ( isPercentage ) {
79+ this . setState ( { value : `${ number - amount } %` } )
80+ } else {
81+ this . setState ( { value : number - amount } )
82+ }
7083 }
7184 }
7285 }
@@ -129,7 +142,7 @@ export class EditableInput extends (PureComponent || Component) {
129142 onChange = { this . handleChange }
130143 onBlur = { this . handleBlur }
131144 placeholder = { this . props . placeholder }
132- spellCheck = "false"
145+ spellCheck = "false"
133146 />
134147 { this . props . label ? (
135148 < span style = { styles . label } onMouseDown = { this . handleMouseDown } >
0 commit comments