From 1ba430d58ea3fd662d09b99f6e22ed3b3564a356 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 03 二月 2023 14:15:31 +0800
Subject: [PATCH] 2023-02-03

---
 src/menu/stylecontroller/styleInput/index.jsx |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/menu/stylecontroller/styleInput/index.jsx b/src/menu/stylecontroller/styleInput/index.jsx
index 8eea049..d7661d0 100644
--- a/src/menu/stylecontroller/styleInput/index.jsx
+++ b/src/menu/stylecontroller/styleInput/index.jsx
@@ -48,6 +48,8 @@
         unit = 'vw'
       } else if (val.indexOf('vh') > -1) {
         unit = 'vh'
+      } else if (val === 'auto' && _options.includes('auto')) {
+        unit = 'auto'
       }
     }
 
@@ -135,8 +137,14 @@
     const { value } = this.state
 
     this.setState({unit: val})
-    if (value && this.props.onChange) {
-      this.props.onChange(`${value}${val}`)
+
+    if (val === 'auto') {
+      this.setState({value: ''})
+      this.props.onChange('auto')
+    } else {
+      if (value && this.props.onChange) {
+        this.props.onChange(`${value}${val}`)
+      }
     }
   }
 
@@ -145,7 +153,7 @@
 
     return (
       <div className="style-input-box">
-        <Input value={value} addonAfter={
+        <Input value={value} disabled={unit === 'auto'} addonAfter={
           options.length > 1 ?
           <Select value={unit} onChange={this.changeUnit}>
             {options.map(item => <Option key={item} value={item}>{item}</Option>)}

--
Gitblit v1.8.0