When changing from a larger part to a smaller part, the previously
existing pins may be removed from the screen but still linked to
elements in the connection graph because we don't set them dirty unless
the changed element overlaps
Fixes #17851
(cherry picked from commit 0cd3e17d)