Fix two issues:
1. popup can only be shown once
2. when height is insufficient the popup position is not correct