Small fix to click-to-select in javascript