Improve determining whether or not to hide sidebar