Skip to content

Commit

Permalink
Fix EdibleInput from rejecting 0% and 1% (#709)
Browse files Browse the repository at this point in the history
Fixes #707
  • Loading branch information
casesandberg authored May 3, 2020
1 parent 6dcb167 commit d97d4d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/components/chrome/ChromeFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react'
import reactCSS from 'reactcss'
import color from '../../helpers/color'
import isUndefined from 'lodash/isUndefined'

import { EditableInput } from '../common'
import UnfoldMoreHorizontalIcon from '@icons/material/UnfoldMoreHorizontalIcon'
Expand Down Expand Up @@ -72,13 +73,20 @@ export class ChromeFields extends React.Component {
}, e)
} else if (data.h || data.s || data.l) {
// Remove any occurances of '%'.
if (typeof(data.s) === 'string' && data.s.includes('%')) { data.s = data.s.replace('%', '') }
if (typeof(data.s) === 'string' && data.s.includes('%')) { data.s = data.s.replace('%', '') }
if (typeof(data.l) === 'string' && data.l.includes('%')) { data.l = data.l.replace('%', '') }


// We store HSL as a unit interval so we need to override the 1 input to 0.01
if (data.s == 1) {
data.s = 0.01
} else if (data.l == 1) {
data.l = 0.01
}

this.props.onChange({
h: data.h || this.props.hsl.h,
s: Number((data.s && data.s) || this.props.hsl.s),
l: Number((data.l && data.l) || this.props.hsl.l),
s: Number(!isUndefined(data.s) ? data.s : this.props.hsl.s),
l: Number(!isUndefined(data.l) ? data.l : this.props.hsl.l),
source: 'hsl',
}, e)
}
Expand Down
1 change: 0 additions & 1 deletion src/components/common/EditableInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class EditableInput extends (PureComponent || Component) {
}

handleChange = (e) => {
console.log(e.target.value)
this.setUpdatedValue(e.target.value, e)
}

Expand Down

0 comments on commit d97d4d7

Please sign in to comment.