Fix selectionChangeHandler throwing typeError because selection is null

Added a guard to check if there is a selection before trying to get the range