Skip to content

Commit

Permalink
Fix drag gesture binding for newer version of react-use-gesture
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Q committed Jan 20, 2021
1 parent 9cfdbb1 commit 70558fa
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions packages/components/src/input-control/input-field.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,29 +183,12 @@ function InputField(
}
);

const { onMouseDown, onTouchStart } = isDragEnabled
? dragGestureProps()
: {};
let handleOnMouseDown = onMouseDown;

/*
* Works around the odd UA (e.g. Firefox) that does not focus inputs of
* type=number when their spinner arrows are pressed.
*/
if ( type === 'number' ) {
handleOnMouseDown = ( event ) => {
if ( event.target !== event.target.ownerDocument.activeElement ) {
event.target.focus();
}
if ( isDragEnabled ) {
onMouseDown( event );
}
};
}
const dragProps = isDragEnabled ? dragGestureProps() : {};

return (
<Input
{ ...props }
{ ...dragProps }
className="components-input-control__input"
disabled={ disabled }
dragCursor={ dragCursor }
Expand All @@ -215,8 +198,6 @@ function InputField(
onChange={ handleOnChange }
onFocus={ handleOnFocus }
onKeyDown={ handleOnKeyDown }
onMouseDown={ handleOnMouseDown }
onTouchStart={ onTouchStart }
ref={ ref }
size={ size }
value={ value }
Expand Down

0 comments on commit 70558fa

Please sign in to comment.