fix preview opening and closing