king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
src/menu/stylecontroller/styleInput/index.jsx
@@ -21,6 +21,8 @@
    options: null
  }
  timer = null
  UNSAFE_componentWillMount () {
    const { defaultValue, value, options } = this.props
    let val = ''
@@ -105,6 +107,7 @@
  }
  changeValue = (e) => {
    const { clear } = this.props
    const { unit } = this.state
    let val = e.target.value
@@ -124,28 +127,34 @@
      value: _val,
    })
    if (this.props.onChange) {
      if (!_val) {
        this.props.onChange('0px')
      } else {
        this.props.onChange(`${_val}${unit}`)
    clearTimeout(this.timer)
    this.timer = setTimeout(() => {
      if (this.props.onChange) {
        if (_val === '') {
          this.props.onChange(clear ? '' : '0px')
        } else {
          this.props.onChange(`${_val}${unit}`)
        }
      }
    }
    }, 100)
  }
  changeUnit = (val) => {
    const { value } = this.state
    this.setState({unit: val})
    if (val === 'auto') {
      this.setState({value: ''})
      this.props.onChange('auto')
    } else {
      if (value && this.props.onChange) {
        this.props.onChange(`${value}${val}`)
    this.setState({unit: val}, () => {
      if (val === 'auto') {
        this.setState({value: ''})
        this.props.onChange('auto')
      } else {
        if (value && this.props.onChange) {
          this.props.onChange(`${value}${val}`)
        } else {
          this.props.onChange('')
        }
      }
    }
    })
  }
  render () {