Fixe indexe out of range error when clicking outside the editor