Skip to content

Commit 9bfaf12

Browse files
husaokonet
authored andcommitted
feat: Allow passing a callback for onDragOver as a prop (react-dropzone#326)
A callback for `onDragOver` event was missing in props. This PR adds it. Closes react-dropzone#325
1 parent ee86ca9 commit 9bfaf12

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ class Dropzone extends React.Component {
6767
} catch (err) {
6868
// continue regardless of error
6969
}
70+
71+
if (this.props.onDragOver) {
72+
this.props.onDragOver.call(this, e);
73+
}
7074
return false;
7175
}
7276

@@ -310,6 +314,7 @@ Dropzone.propTypes = {
310314
onDropRejected: React.PropTypes.func,
311315
onDragStart: React.PropTypes.func,
312316
onDragEnter: React.PropTypes.func,
317+
onDragOver: React.PropTypes.func,
313318
onDragLeave: React.PropTypes.func,
314319

315320
children: React.PropTypes.node, // Contents of the dropzone

src/index.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,23 @@ describe('Dropzone', () => {
165165
it('should override onDrag* methods', () => {
166166
const dragStartSpy = spy();
167167
const dragEnterSpy = spy();
168+
const dragOverSpy = spy();
168169
const dragLeaveSpy = spy();
169170
const component = mount(
170171
<Dropzone
171172
onDragStart={dragStartSpy}
172173
onDragEnter={dragEnterSpy}
174+
onDragOver={dragOverSpy}
173175
onDragLeave={dragLeaveSpy}
174176
/>
175177
);
176178
component.simulate('dragStart');
177179
component.simulate('dragEnter', { dataTransfer: { items: files } });
180+
component.simulate('dragOver', { dataTransfer: { items: files } });
178181
component.simulate('dragLeave', { dataTransfer: { items: files } });
179182
expect(dragStartSpy.callCount).toEqual(1);
180183
expect(dragEnterSpy.callCount).toEqual(1);
184+
expect(dragOverSpy.callCount).toEqual(1);
181185
expect(dragLeaveSpy.callCount).toEqual(1);
182186
});
183187

0 commit comments

Comments
 (0)