Skip to content

Commit e599da7

Browse files
author
Claudéric Demers
authored
Merge pull request clauderic#260 from cameronmcefee/set-window-default-manually
Set contentWindow default ourselves to avoid Jest serialization
2 parents 0095e6e + d080f32 commit e599da7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/SortableContainer/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
4444
distance: 0,
4545
useWindowAsScrollContainer: false,
4646
hideSortableGhost: true,
47-
contentWindow: typeof window !== 'undefined' ? window : null,
4847
shouldCancelStart: function(e) {
4948
// Cancel sorting if the event target is an `input`, `textarea`, `select` or `option`
5049
const disabledElements = ['input', 'textarea', 'select', 'option', 'button'];
@@ -100,11 +99,17 @@ export default function sortableContainer(WrappedComponent, config = {withRef: f
10099

101100
componentDidMount() {
102101
const {
103-
contentWindow,
104102
getContainer,
105103
useWindowAsScrollContainer,
106104
} = this.props;
107105

106+
/*
107+
* Set our own default rather than using defaultProps because Jest
108+
* snapshots will serialize window, causing a RangeError
109+
* https://github.com/clauderic/react-sortable-hoc/issues/249
110+
*/
111+
const contentWindow = this.props.contentWindow || window;
112+
108113
this.container = typeof getContainer === 'function'
109114
? getContainer(this.getWrappedInstance())
110115
: findDOMNode(this);

0 commit comments

Comments
 (0)