Skip to content

Commit a2a9bc4

Browse files
authored
feat(dropdowns): Add hide() and show() methods (bootstrap-vue#1012)
Addresses issue bootstrap-vue#1011
1 parent 9fae398 commit a2a9bc4

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

lib/mixins/dropdown.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ export default {
117117
} else {
118118
this.hideMenu();
119119
}
120+
},
121+
disabled(state, old) {
122+
if (state !== old && state && this.visible) {
123+
// Hide dropdown if disabled changes to true
124+
this.visible = false;
125+
}
120126
}
121127
},
122128
computed: {
@@ -239,13 +245,27 @@ export default {
239245
this.$emit("click", e);
240246
},
241247
toggle() {
242-
// Called only by a button that toggles teh menu
248+
// Called only by a button that toggles the menu
243249
if (this.disabled) {
244250
this.visible = false;
245251
return;
246252
}
247253
this.visible = !this.visible;
248254
},
255+
show() {
256+
// Public method to show dropdown
257+
if (this.disabled) {
258+
return;
259+
}
260+
this.visible = true;
261+
},
262+
hide() {
263+
// Public method to hide dropdown
264+
if (this.disabled) {
265+
return;
266+
}
267+
this.visible = false;
268+
},
249269
onTab() {
250270
if (this.visible) {
251271
// TODO: Need special handler for dealing with form inputs

0 commit comments

Comments
 (0)