add state for popup history, fix bug of intermediate history state between popups