I have this bootstrap dropdown here. What I want to do is to change the background color of the button to blue only when the dropdown menu is expanded. I achieve it by styling it through adding a click listener to the button but the issue is when the menu is expanded and the user clicks somewhere else, the menu goes hidden while the button is still blue. How can I modify it so the button is blue ONLY AND ONLY when the menu is expanded?
here is my code:
//template
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" :style="test ? clickedBtn : null" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" @click="testing()">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div>
//script
data: {
test: false,
clickedBtn: {
background: "blue",
color: "white"
}
},
methods: {
testing(){
this.test = !this.test
}
}