fix crash when text is empty && add delegate to get selected tag's index