Skip to content

Commit

Permalink
fix: use selection helper for arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Mar 24, 2021
1 parent 7ede88b commit 9651fcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/keyboard/plugins/arrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import {behaviorPlugin} from '../types'
import {isElementType, setSelectionRange} from '../../utils'
import {getSelectionRange, isElementType, setSelectionRange} from '../../utils'

export const keydownBehavior: behaviorPlugin[] = [
{
Expand All @@ -13,7 +13,7 @@ export const keydownBehavior: behaviorPlugin[] = [
(keyDef.key === 'ArrowLeft' || keyDef.key === 'ArrowRight') &&
isElementType(element, 'input'),
handle: (keyDef, element) => {
const {selectionStart, selectionEnd} = element as HTMLInputElement
const {selectionStart, selectionEnd} = getSelectionRange(element)

const direction = keyDef.key === 'ArrowLeft' ? -1 : 1

Expand Down

0 comments on commit 9651fcf

Please sign in to comment.