Optimized the event handler for the theme
Merge pull request #3071 from LaurentGoderre/v4.0

Optimized the event handler for the theme