Skip to content

Commit 080bb20

Browse files
authored
feat(alert): Hide dismiss button for auto-dismissing alerts (bootstrap-vue#791)
* feat(alert): Hide dismiss button for auto-dismissing * [alert] Update README.md * [alert] update example files
1 parent c234580 commit 080bb20

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

docs/components/alert/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Dismissible Alert!
1818
</b-alert>
1919

20-
<b-alert :show="dismissCountDown" dismissible variant="warning" @dismiss-count-down="countDownChanged">
20+
<b-alert :show="dismissCountDown" variant="warning" @dismiss-count-down="countDownChanged">
2121
This alert will dismiss after {{dismissCountDown}} seconds...
2222
</b-alert>
2323

@@ -76,3 +76,5 @@ with the dismiss button.
7676
#### Auto dismissing alerts:
7777
To create a `<b-alert>` that dismisses automatically after a period of time, set
7878
the `show` prop to the number of seconds you would like the `<b-alert>` to remain visible for.
79+
80+
Note that the dismiss button will not be shown for auto-dismissing alerts.

examples/alert/demo.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
</b-alert>
2323

2424
<b-alert :show="dismissCountDown"
25-
dismissible
2625
variant="warning"
2726
@dismiss-count-down="countDownChanged"
2827
>
@@ -34,4 +33,4 @@
3433
<b-btn @click="showDismissibleAlert=true" variant="info" class="m-1" ref="dismissible_alert_btn">
3534
Show dismissible alert ({{showDismissibleAlert?'visible':'hidden'}})
3635
</b-btn>
37-
</div>
36+
</div>

lib/components/alert.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class="close"
1010
data-dismiss="alert"
1111
:aria-label="dismissLabel"
12-
v-if="dismissible"
12+
v-if="localDismissible"
1313
@click.stop.prevent="dismiss"
1414
>
1515
<span aria-hidden="true">&times;</span>
@@ -25,7 +25,8 @@
2525
data() {
2626
return {
2727
countDownTimerId: null,
28-
dismissed: false
28+
dismissed: false,
29+
localDismissible: this.dismissible
2930
};
3031
},
3132
created() {
@@ -35,7 +36,7 @@
3536
},
3637
computed: {
3738
classObject() {
38-
return ['alert', this.alertVariant, this.dismissible ? 'alert-dismissible' : ''];
39+
return ['alert', this.alertVariant, this.localDismissible ? 'alert-dismissible' : ''];
3940
},
4041
alertVariant() {
4142
const variant = this.state || this.variant || 'info';
@@ -92,9 +93,13 @@
9293
9394
// No timer for boolean values
9495
if (this.show === true || this.show === false || this.show === null || this.show === 0) {
96+
this.localDismissible = this.dismissible;
9597
return;
9698
}
9799
100+
// Hide dismiss button for auto-dismissing
101+
this.localDismissible = false;
102+
98103
let dismissCountDown = this.show;
99104
this.$emit('dismiss-count-down', dismissCountDown);
100105

0 commit comments

Comments
 (0)