Permalink
Browse files

feat: Allow passing a callback for onDragOver as a prop (#326)

A callback for `onDragOver` event was missing in props. This PR adds it.

Closes #325
  • Loading branch information...
1 parent ee86ca9 commit 9bfaf129cd4022a25da6ca751afd96c27422ea29 @husa husa committed with Jan 12, 2017
Showing with 9 additions and 0 deletions.
  1. +5 −0 src/index.js
  2. +4 −0 src/index.spec.js
View
@@ -67,6 +67,10 @@ class Dropzone extends React.Component {
} catch (err) {
// continue regardless of error
}
+
+ if (this.props.onDragOver) {
+ this.props.onDragOver.call(this, e);
+ }
return false;
}
@@ -310,6 +314,7 @@ Dropzone.propTypes = {
onDropRejected: React.PropTypes.func,
onDragStart: React.PropTypes.func,
onDragEnter: React.PropTypes.func,
+ onDragOver: React.PropTypes.func,
onDragLeave: React.PropTypes.func,
children: React.PropTypes.node, // Contents of the dropzone
View
@@ -165,19 +165,23 @@ describe('Dropzone', () => {
it('should override onDrag* methods', () => {
const dragStartSpy = spy();
const dragEnterSpy = spy();
+ const dragOverSpy = spy();
const dragLeaveSpy = spy();
const component = mount(
<Dropzone
onDragStart={dragStartSpy}
onDragEnter={dragEnterSpy}
+ onDragOver={dragOverSpy}
onDragLeave={dragLeaveSpy}
/>
);
component.simulate('dragStart');
component.simulate('dragEnter', { dataTransfer: { items: files } });
+ component.simulate('dragOver', { dataTransfer: { items: files } });
component.simulate('dragLeave', { dataTransfer: { items: files } });
expect(dragStartSpy.callCount).toEqual(1);
expect(dragEnterSpy.callCount).toEqual(1);
+ expect(dragOverSpy.callCount).toEqual(1);
expect(dragLeaveSpy.callCount).toEqual(1);
});

0 comments on commit 9bfaf12

Please sign in to comment.