Explorar o código

fix: 地区级联懒加载时,onBlur先于loadData调用导致editForm退出编辑

lanjianrong %!s(int64=5) %!d(string=hai) anos
pai
achega
4e4e04b3cd

+ 3 - 5
src/components/EditableForm/src/editableFormItem.jsx

@@ -45,8 +45,9 @@ const EditableFormItem = ({
       if (iRef.current.selectRef) {
         // select选择器相关
         iRef.current.selectRef.current.focus()
-      } else if (iRef.current.cascadeRef) {
-        iRef.current.cascadeRef.current.focus()
+      } else if (editCellType === 'cascader') {
+        return
+        // iRef.current.cascadeRef.current.focus()
       } else {
         iRef.current.focus()
       }
@@ -127,8 +128,6 @@ const EditableFormItem = ({
     }
   }
   const save = async e => {
-    // console.log('失去焦点了', e)
-    // console.log(e)
     const { value, local = '' } = e.currentTarget
     if (value === record || !value) {
       toggleEdit()
@@ -152,7 +151,6 @@ const EditableFormItem = ({
             defaultValue={state.val}
             allowClear={false}
             className="w-full"
-            autoFocus={true}
             onChange={(value, local) => save({ currentTarget: { value, local } })}
             popupVisible={true}
             onBlur={save}

+ 0 - 7
src/components/LazyCascader/LazyCascader.jsx

@@ -4,16 +4,12 @@ import { connect } from 'dva'
 
 const CLazyCascader = props => {
   const { refinstance, options, dispatch, onChange, changeOnSelect = false, ...resetProps } = props
-  // console.log(props.defaultValue)
   useEffect(() => {
     if (!options.length) {
       dispatch({
         type: 'district/fetch'
       })
     }
-    // if (refinstance && refinstance.current) {
-    //   refinstance.current.focus()
-    // }
   }, [])
 
   const triggerChange = (value, local = '') => {
@@ -58,6 +54,3 @@ const LazyCascader = connect(({ district }) => ({
 export default forwardRef((props, ref) => {
   return <LazyCascader {...props} refinstance={ref} />
 })
-// export default connect(({ district }) => ({
-//   options: district.data
-// }))(LazyCascader)