hide legend when popup is closed