fixes #17157. Fixes the case "popup menu closes immediately after scrolling" - thanks Sergey Grebnov (CLA).