Button of SelectBox dows not move when changing width of box

I am creating a SelectBox with some default width and afterwards fill it with items and check if the items fit into the box. If not, the width of the box is set so that the item fits the box. But when running the code i see that the little box that opens the menu for the items did not move and howers over the textbox.