Skip to content

Commit bcb7b3f

Browse files
committed
fix: CToast: fix appear animation and SSR
1 parent 39596d5 commit bcb7b3f

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

src/components/toast/CToast.vue

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
2-
<transition :name="props.fade ? 'fade' : null" appear>
2+
<transition :name="props.fade ? 'fade' : null" :appear="true">
33
<div
4-
v-show="isShowed"
5-
:class="toastClasses"
4+
v-if="isShowed"
5+
class="toast"
66
role="alert"
77
aria-live="assertive"
88
aria-atomic="true"
@@ -48,30 +48,21 @@ export default {
4848
},
4949
data () {
5050
return {
51-
isShowed: false,
51+
isShowed: this.show,
5252
hidding: false,
5353
timeout: null,
5454
hiddingTimeout: null
5555
}
5656
},
5757
watch: {
58-
show (val) {
59-
val ? this.display() : this.close()
58+
show: {
59+
immediate: true,
60+
handler (val) {
61+
val ? this.display() : this.close()
62+
}
6063
}
6164
},
62-
//needed not to be called in show watcher to allow SSR
63-
mounted () {
64-
this.show ? this.display() : this.close()
65-
},
6665
computed: {
67-
toastClasses () {
68-
return [
69-
'toast',
70-
{
71-
'show': this.isShowed,
72-
}
73-
]
74-
},
7566
directlyDeclaredProps () {
7667
return Object.keys(this.$options.propsData)
7768
},
@@ -94,8 +85,9 @@ export default {
9485
this.$nextTick(() => {
9586
if (this.props.autohide) {
9687
this.setAutohide()
88+
} else if (this.hidding === true) {
89+
this.finishHidding()
9790
}
98-
this.finishHidding()
9991
})
10092
},
10193
close (restoreOnHover = false) {
@@ -148,6 +140,9 @@ export default {
148140
</script>
149141

150142
<style scoped>
143+
.toast {
144+
opacity: inherit;
145+
}
151146
.fade-enter-active {
152147
transition: opacity .5s;
153148
}

src/components/toast/tests/__snapshots__/CToast.spec.js.snap

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
exports[`CToast renders correctly 1`] = `
44
<div
5-
appear=""
5+
appear="true"
66
aria-atomic="true"
77
aria-live="assertive"
8-
class="toast show"
8+
class="toast"
99
position="static"
1010
role="alert"
11-
style=""
1211
>
1312
<!---->
1413
@@ -20,14 +19,13 @@ exports[`CToast renders correctly 1`] = `
2019

2120
exports[`CToast renders correctly custom wrapper 1`] = `
2221
<div
23-
appear=""
22+
appear="true"
2423
aria-atomic="true"
2524
aria-live="assertive"
26-
class="toast show"
25+
class="toast"
2726
name="fade"
2827
position="bottom-center"
2928
role="alert"
30-
style=""
3129
>
3230
<div
3331
class="toast-header"

src/components/toast/tests/__snapshots__/CToaster.spec.js.snap

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ exports[`CToaster renders correctly custom wrapper 1`] = `
1111
class="toaster toaster-top-left"
1212
>
1313
<div
14-
appear=""
14+
appear="true"
1515
aria-atomic="true"
1616
aria-live="assertive"
17-
class="toast show"
17+
class="toast"
1818
role="alert"
19-
style=""
2019
>
2120
<!---->
2221

0 commit comments

Comments
 (0)