Prevent horizontal scrollbar appearance if an error message is too long
(cherry picked from commit cb20ef5)
possible race condition fixed
(cherry picked from commit 97a6a21)