Prevent modal dialog from exceeding window height

This is for #6395.

I've seen this when I don't remember a modal dialog exceeding window height, so there may be other causes.

The problem is that sidebar gets stretched out-of-shape but doesn't get refreshed properly. This fix prevents modal dialogs from stretching window out-of-shape.

I think problem with sidebar not getting refreshed properly is because its layout is not pure CSS (i.e. uses JS). For some reason modal dialog exceeding window height does not trigger resize events. This is probably because modal dialog is inside a display:table and/or position:relative/absolute container.