22 <div v-if =" isAlertVisible" ref =" element" class =" alert" role =" alert" :class =" classes" >
33 <slot />
44 <template v-if =" dismissibleBoolean " >
5- <button
6- v-if =" $slots.dismissible"
7- type =" button"
8- data-bs-dismiss =" alert"
9- @click =" dismissClicked"
10- >
11- <slot name =" dismissible" />
5+ <button v-if =" $slots.dismissible" type =" button" data-bs-dismiss =" alert" @click =" closeClicked" >
6+ <slot name =" dismiss" />
127 </button >
138 <b-close-button
149 v-else
1510 :aria-label =" dismissLabel"
1611 data-bs-dismiss =" alert"
17- @click =" dismissClicked "
12+ @click =" closeClicked "
1813 />
1914 </template >
2015 </div >
@@ -54,21 +49,22 @@ const fadeBoolean = useBooleanish(toRef(props, 'fade'))
5449const showBoolean = useBooleanish (toRef (props , ' show' ))
5550
5651interface BAlertEmits {
57- // TODO rename dismissed to closed
58- (e : ' dismissed' ): void
59- (e : ' dismiss-count-down' , value : number ): void
52+ (e : ' closed' ): void
53+ (e : ' close-count-down' , value : number ): void
6054 (e : ' update:modelValue' , value : boolean | number ): void
6155}
6256
6357const emit = defineEmits <BAlertEmits >()
6458
65- const element = ref <HTMLElement >( )
59+ const element = ref <HTMLElement | null >( null )
6660const instance = ref <Alert >()
6761const classes = computed (() => ({
6862 [` alert-${props .variant } ` ]: !! props .variant ,
6963 ' show' : !! props .modelValue ,
7064 ' alert-dismissible' : dismissibleBoolean .value ,
7165 // TODO it seems like fade is probably used here
66+ // It seems like the issue with trying to set fade is that when using transitions,
67+ // The element is null when it's trying to set the transition
7268 ' fade' : !! props .modelValue ,
7369}))
7470
@@ -117,13 +113,13 @@ const handleShowAndModelChanged = (): void => {
117113 instance .value = new Alert (element .value as HTMLElement )
118114}
119115
120- const dismissClicked = (): void => {
116+ const closeClicked = (): void => {
121117 if (typeof props .modelValue === ' boolean' ) {
122118 emit (' update:modelValue' , false )
123119 } else {
124120 emit (' update:modelValue' , 0 )
125121 }
126- emit (' dismissed ' )
122+ emit (' closed ' )
127123}
128124
129125watch (() => props .modelValue , handleShowAndModelChanged )
@@ -132,9 +128,9 @@ watch(() => showBoolean.value, handleShowAndModelChanged)
132128watch (countDown , (newValue ) => {
133129 clearCountDownInterval ()
134130 if (typeof props .modelValue === ' boolean' ) return
135- emit (' dismiss -count-down' , newValue )
131+ emit (' close -count-down' , newValue )
136132
137- if (newValue === 0 && props .modelValue > 0 ) emit (' dismissed ' )
133+ if (newValue === 0 && props .modelValue > 0 ) emit (' closed ' )
138134 if (props .modelValue !== newValue ) emit (' update:modelValue' , newValue )
139135 if (newValue > 0 ) {
140136 _countDownTimeout = setTimeout (() => {
0 commit comments