Wait for the expected target during a collapse

Actually wait for the collapsed item to complete. If complete is called
with other target, instead of simply returning and do nothing, wait again
until the proper target triggers the event (otherwise this leaves collapse
in a broken state).
Merge pull request #13330 from Kronuz/patch-1

Wait for the expected target during a collapse