Fix detection of hidden legends