Handle templates correctly on selected item