Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Dialog closed without transition if update value in close event #1216

Closed
xyorz opened this issue Jan 7, 2021 · 13 comments
Closed
Assignees
Labels
🔨 Vue issue Issue caused by Vue. Can't do anything

Comments

@xyorz
Copy link
Contributor

xyorz commented Jan 7, 2021

Element Plus version

1.0.1-beta.22

OS/Browsers version

Google Chrome 87.0.4280.141

Vue version

3.0.5

Reproduction Link

https://codepen.io/xyorz/pen/ExgRvZO

Steps to reproduce

1.open dialog.
2.close dialog.
It works in vue@3.0.3 but not as well as vue@3.0.4 and later.
I'm not quite sure this bug is caused by element-plus or vue.

What is Expected?

Dialog closed with transition.

What is actually happening?

Dialog closed without transition.

@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

https://element-plus.org/#/zh-CN/component/dialog Dunno what happened but doc site is working fine. I'll verify it locally.

@jw-foss jw-foss self-assigned this Jan 7, 2021
@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

Confirmed locally, will fix.

@jw-foss jw-foss added Project::Bug Something isn't working Level::P0 highest priority and removed Issue::Investigating labels Jan 7, 2021
@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

I double checked the code.
When you pass this into the template:

  <span>需要注意的是内容是默认不居中的{{counter}}</span>

The transition closes immediately.
This might not be a bug from us, it could be a bug from vue.

@xyorz
Copy link
Contributor Author

xyorz commented Jan 7, 2021

I found it works correctly in element-plus@1.0.1-beta.18 and previous versions.
Maybe some change cause it.

@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

Same version of Vue@3.0.5?

@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

I double checked the code, before v1.0.1-beta.18, we emit close event in modelValue's watcher, after the very version, we emit close event in onBeforeLeave hook in Transition, so I think the root cause is Vue transition.

@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

I changed Vue's version back to @3.0.3 the error no long appears. But we know that Vue had lethal bug on emitting events @ version 3.0.3. So I upgrade to 3.0.4 it appears again. So that I think the bug itself is caused by Vue transition. For temporary fix I think you need to move your value manipulation in @closed event instead of close event.

@xyorz
Copy link
Contributor Author

xyorz commented Jan 7, 2021

I see. Thanks for your help.

@jw-foss jw-foss removed the Level::P0 highest priority label Jan 7, 2021
@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

Confirmed as a Vue bug, check this out:
vuejs/core#2757
vuejs/core#2961

@jw-foss
Copy link
Member

jw-foss commented Jan 7, 2021

The fix is rather simple, we can switch vShow to vIf but that way we can not enable animation. Had to wait for them to fix that.

@jw-foss jw-foss added 🔨 Vue issue Issue caused by Vue. Can't do anything and removed Project::Bug Something isn't working labels Jan 7, 2021
@duansheli
Copy link

bug report

when swith page , auto select checkbox not work

full code

<template>
  <el-dialog title="角色人员关联" v-model="showtb" width="55%" destroy-on-close>
    <el-table ref="tb1" border style="width: 100%" :data="tb1Data">
      <el-table-column type="selection" width="80" />
      <el-table-column prop="id" label="id" width="100" />
    </el-table>

    <el-button @click="test1" type="primary" size="small"> test1 </el-button>
    <el-button @click="test2" type="primary" size="small"> test2 </el-button>
  </el-dialog>
</template>
<script setup lang="ts">
import { ref } from "vue";

const arr = [{ id: 1 }, { id: 2 }];

const showtb = ref(true);

const tb1 = ref(null);
const tb1Data = ref([]);
tb1Data.value = [...arr];
let num = 3;

function test1() {
  // mock switch page 
  const a = { id: num };
  num++;

  {
    // good-mode
    tb1Data.value.push(a);
  }
  {
    // bad-mode
    arr.push(a);
    tb1Data.value = [...arr];
  }

  test2(); 
}
function test2() {
  tb1.value.toggleRowSelection(tb1Data.value[1], true);
}
</script>

with this code

 {
    tb1Data.value.push(a);
  }

checkbox will select


with this code

  {
    arr.push(a);
    tb1Data.value = [...arr];
  }

checkbox won't select

@duansheli
Copy link

@JeremyWuuuuu
在 Dialog 中 使用table
在 mounted 阶段 无法获取到 table组件的引用

解决办法为:
在 Dialog 的 opened 事件发生阶段 可获取到table组件的引用
于是对 table 的 自动勾选 放在了opened 事件中

不知道这算不算个bug

@Ryan2128
Copy link
Member

Ryan2128 commented Mar 2, 2021

New version of vue has been released. If still has problem, please reopen this issue.

@Ryan2128 Ryan2128 closed this as completed Mar 2, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 Vue issue Issue caused by Vue. Can't do anything
Projects
None yet
Development

No branches or pull requests

4 participants