Update avoidTextSelection function.