fixes #5170 JS Error when you click on Dashboard

Fixed the issue and pushed the code for review, please check it.