I have an Excel-style grid of inputs and I want to use the left right arrow keys to navigate between cells, but only when there are no characters in the input, or when the cursor is to the far left or right of the characters. So I've got:
console.log('selectionStart: ', currentCell.nativeElement.selectionStart);
console.log('selectionEnd: ', currentCell.nativeElement.selectionEnd);
where currentCell is an ElementRef. However, no matter where the cursor is with the characters, both of these always return null (if nothing is selected, both selectionStart
and selectionEnd
should return the same integer value; if there is a selection, these should be different values, but there should always be a value). Any ideas on why this might not be working?