Draw dropdowns in the available space

Avoiding to overflow the parent container. Related to #906

(cherry picked from commit 01092475948fb43584c253277211d823c171dc2a)