Fix for #4550

Also fixes dropdowns hiding behavior for case when two or more dropdowns
with [data-toggle=dropdown] exist on the page
Merge pull request #5323 from artiz/master

Please check my fix for #4550