Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit ddcc3ed

Browse files
committed
feat(BAlert): re-add closeContent prop and emit closed.
1 parent ee7c91e commit ddcc3ed

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

packages/bootstrap-vue-next/src/components/BAlert/BAlert.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
>
1313
<slot />
1414
<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>
1719
</BButton>
1820
<BCloseButton v-else v-bind="closeAttrs" @click="hide" />
1921
</template>
@@ -37,6 +39,7 @@ const props = withDefaults(
3739
closeClass?: ClassValue
3840
closeLabel?: string
3941
closeWhite?: Booleanish
42+
closeContent?: string
4043
noHoverPause?: Booleanish
4144
dismissible?: Booleanish
4245
fade?: Booleanish
@@ -51,6 +54,7 @@ const props = withDefaults(
5154
closeClass: undefined,
5255
closeLabel: 'Close',
5356
closeWhite: false,
57+
closeContent: undefined,
5458
noHoverPause: false,
5559
interval: 1000,
5660
dismissible: false,
@@ -64,6 +68,7 @@ const props = withDefaults(
6468
6569
const emit = defineEmits<{
6670
'close': []
71+
'closed': []
6772
'close-countdown': [value: number]
6873
'update:modelValue': [value: boolean | number]
6974
}>()
@@ -134,6 +139,8 @@ const hide = (): void => {
134139
modelValue.value = 0
135140
stop()
136141
}
142+
143+
emit('closed')
137144
}
138145
139146
// TODO mouseleave/mouseenter could be replaced with useElementHover with a watcher

packages/bootstrap-vue-next/src/components/BAlert/alert.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,24 @@ describe('alert', () => {
156156
expect($bclosebutton.exists()).toBe(false)
157157
})
158158

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+
159177
it('nested div has BButton when prop dismissible but also slot close', () => {
160178
const wrapper = mount(BAlert, {
161179
props: {modelValue: true, dismissible: true},

0 commit comments

Comments
 (0)