Skip to content

Commit

Permalink
Fix #491
Browse files Browse the repository at this point in the history
  • Loading branch information
sekoyo committed Jun 13, 2022
1 parent 645caed commit 715b916
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-image-crop",
"version": "10.0.2",
"version": "10.0.3",
"description": "A responsive image cropping tool for React",
"repository": "https://github.com/DominicTobias/react-image-crop",
"main": "dist/ReactCrop.min.js",
Expand Down
9 changes: 8 additions & 1 deletion src/ReactCrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,13 @@ class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
}
}

onDragFocus = (e: React.FocusEvent<HTMLDivElement, Element>) => {
// Fixes #491
if (this.componentRef.current?.scrollTop) {
this.componentRef.current.scrollTop = 0
}
}

getCropStyle() {
const { crop } = this.props

Expand Down Expand Up @@ -738,7 +745,7 @@ class ReactCrop extends PureComponent<ReactCropProps, ReactCropState> {
onKeyUp={this.onComponentKeyUp}
>
{!disabled && !locked && (
<div className="ReactCrop__drag-elements">
<div className="ReactCrop__drag-elements" onFocus={this.onDragFocus}>
<div className="ReactCrop__drag-bar ord-n" data-ord="n" />
<div className="ReactCrop__drag-bar ord-e" data-ord="e" />
<div className="ReactCrop__drag-bar ord-s" data-ord="s" />
Expand Down

0 comments on commit 715b916

Please sign in to comment.