This can be achieved by adding the css property break-inside to the child items.
Adding the following to the css in your codepen achieves the desired effect:
.sub-menu{ break-inside: avoid; }