better mouseup handling
(cherry picked from commit e3c2123041578ca0d8ca61bff7843acf08e33121)