element-plus [Component] el-form嵌套带dialog的子组件 disabled以后 dialog内层按钮都没法使用。

aurhwmvo  于 4个月前  发布在  其他
关注(0)|答案(2)|浏览(123)

Bug Type: Component

Environment

  • Vue Version: 3.2.45
  • Element Plus Version: 2.2.26
  • Browser / OS: UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
  • Build Tool: Vite

Reproduction

  • el-dialog
  • el-form
  • el-form-item

Element Plus Playground

Steps to reproduce

<script setup lang="ts">
import { ref, version as vueVersion } from 'vue'
import { version as EpVersion } from 'element-plus'
import { ElementPlus } from '@element-plus/icons-vue'
import comp from './Comp.vue'
const msg = ref('Hello World!')
</script>

<template>
  <el-form disabled>
  	<el-form-item label="label测试">
    	<comp></comp>
    </el-form-item>
  </el-form>
</template>

###子组件

<script setup lang="ts">
import { ref, version as vueVersion } from 'vue'
import { version as EpVersion } from 'element-plus'
import { ElementPlus } from '@element-plus/icons-vue'

const msg = ref('Hello World!')
const visibled = ref(false)
const initDialog = ()=>{
  visibled.value= true
}
defineExpose({
  initDialog
})
</script>
<style>
  p{
    margin: 0;
    padding: 0;
    color: blue;
  }
</style>
<template>
  <p @click="initDialog">打开详情信息</p>
  <el-dialog v-model="visibled">
  	<template #footer>
    	<el-button type="primary" @click="visibled = false">关闭弹窗</el-button>
    </template>
  </el-dialog>
</template>

What is Expected?

el-dialog按钮不应该被禁用

What is actually happening?

el-dialog按钮被禁用

Additional comments

希望优化

tgabmvqs

tgabmvqs1#

由于组件内部会通过inject el-form的配置得到最终的disabled,它处于禁用的form下面,那它一定是禁用状态,我认为这个默认表现上是没问题的,至于是否要优化或者怎么优化还需要讨论一下,建议在discussions发起讨论。
临时解决方案就是给你的dialog内部套一个el-form

qvsjd97n

qvsjd97n2#

在旧版的是做了一次修改的,可以参考 @chenxch
ElemeFE/element#21375

相关问题