This repository was archived by the owner on Mar 27, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
packages/bootstrap-vue-next/src/components/BAlert Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 12
12
>
13
13
<slot />
14
14
<template v-if =" dismissibleBoolean " >
15
- <BButton v-if =" hasCloseSlot" v-bind =" closeAttrs" @click =" hide" >
16
- <slot name =" close" />
15
+ <BButton v-if =" hasCloseSlot || closeContent" v-bind =" closeAttrs" @click =" hide" >
16
+ <slot name =" close" >
17
+ {{ closeContent }}
18
+ </slot >
17
19
</BButton >
18
20
<BCloseButton v-else v-bind =" closeAttrs" @click =" hide" />
19
21
</template >
@@ -37,6 +39,7 @@ const props = withDefaults(
37
39
closeClass? : ClassValue
38
40
closeLabel? : string
39
41
closeWhite? : Booleanish
42
+ closeContent? : string
40
43
noHoverPause? : Booleanish
41
44
dismissible? : Booleanish
42
45
fade? : Booleanish
@@ -51,6 +54,7 @@ const props = withDefaults(
51
54
closeClass: undefined ,
52
55
closeLabel: ' Close' ,
53
56
closeWhite: false ,
57
+ closeContent: undefined ,
54
58
noHoverPause: false ,
55
59
interval: 1000 ,
56
60
dismissible: false ,
@@ -64,6 +68,7 @@ const props = withDefaults(
64
68
65
69
const emit = defineEmits <{
66
70
' close' : []
71
+ ' closed' : []
67
72
' close-countdown' : [value : number ]
68
73
' update:modelValue' : [value : boolean | number ]
69
74
}>()
@@ -134,6 +139,8 @@ const hide = (): void => {
134
139
modelValue .value = 0
135
140
stop ()
136
141
}
142
+
143
+ emit (' closed' )
137
144
}
138
145
139
146
// TODO mouseleave/mouseenter could be replaced with useElementHover with a watcher
Original file line number Diff line number Diff line change @@ -156,6 +156,24 @@ describe('alert', () => {
156
156
expect ( $bclosebutton . exists ( ) ) . toBe ( false )
157
157
} )
158
158
159
+ it ( 'nested div does not have BCloseButton when prop dismissible but also prop closeContent' , ( ) => {
160
+ const wrapper = mount ( BAlert , {
161
+ props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
162
+ } )
163
+ const $div = wrapper . get ( 'div' )
164
+ const $bclosebutton = $div . findComponent ( BCloseButton )
165
+ expect ( $bclosebutton . exists ( ) ) . toBe ( false )
166
+ } )
167
+
168
+ it ( 'nested div has BButton when prop dismissible but also prop closeContent' , ( ) => {
169
+ const wrapper = mount ( BAlert , {
170
+ props : { modelValue : true , dismissible : true , closeContent : 'foobar' } ,
171
+ } )
172
+ const $div = wrapper . get ( 'div' )
173
+ const $bbutton = $div . findComponent ( BButton )
174
+ expect ( $bbutton . exists ( ) ) . toBe ( true )
175
+ } )
176
+
159
177
it ( 'nested div has BButton when prop dismissible but also slot close' , ( ) => {
160
178
const wrapper = mount ( BAlert , {
161
179
props : { modelValue : true , dismissible : true } ,
You can’t perform that action at this time.
0 commit comments