Prevent corrupted measurements due to vanishing/appearing scrollbar

Issue #1787