Fix a bug messing with selected item index when inserting some item