This change fixes a bug where we the context was wrong after putting the IP in a new location by mouse-click. Fixes #8024. (cherry picked from commit a085fa24)