Fixes issue #3740 for horizontal layouts

Fixes issue #3740 for horizontal layouts