Fix the panel visibility bug