Fix bug when editing selected item