Skip to content

Commit b3663d6

Browse files
author
Edward Xiao
committed
- globalObject: 'this',
1 parent 531b274 commit b3663d6

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

lib/components/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-inputs-validation.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-inputs-validation",
3-
"version": "4.2.0",
3+
"version": "4.2.2",
44
"description": "React form input validation components",
55
"main": "index.js",
66
"repository": {

src/js/Inputs/Select.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const component: React.FC<Props> = ({
197197
}
198198
}, []);
199199
const handleOnChange = useCallback((item: object, e: React.MouseEvent<HTMLElement>) => {
200-
if (disabled || $elWrapper === null) {
200+
if (disabled) {
201201
return;
202202
}
203203
onChange && onChange(item, e);
@@ -236,20 +236,19 @@ const component: React.FC<Props> = ({
236236
}, []);
237237
/* istanbul ignore next because of https://github.com/airbnb/enzyme/issues/441 && https://github.com/airbnb/enzyme/blob/master/docs/future.md */
238238
useEffect(() => {
239-
if ($elWrapper === null) {
240-
return;
239+
if (typeof window !== 'undefined') {
240+
window.addEventListener('mousedown', pageClick);
241+
window.addEventListener('touchstart', pageClick);
242+
return () => {
243+
window.removeEventListener('mousedown', pageClick);
244+
window.removeEventListener('touchstart', pageClick);
245+
$elWrapper.current.removeEventListener('keydown', onKeyDown);
246+
};
241247
}
242-
window.addEventListener('mousedown', pageClick);
243-
window.addEventListener('touchstart', pageClick);
244-
return () => {
245-
window.removeEventListener('mousedown', pageClick);
246-
window.removeEventListener('touchstart', pageClick);
247-
$elWrapper.current.removeEventListener('keydown', onKeyDown);
248-
};
249248
}, []);
250249
/* istanbul ignore next because of https://github.com/airbnb/enzyme/issues/441 && https://github.com/airbnb/enzyme/blob/master/docs/future.md */
251250
const pageClick = useCallback((e: Event) => {
252-
if ($elWrapper === null || $elWrapper.current.contains(e.target)) {
251+
if ($elWrapper.current.contains(e.target)) {
253252
return;
254253
}
255254
if (globalVariableIsFocusing) {
@@ -276,9 +275,6 @@ const component: React.FC<Props> = ({
276275
const scroll = useCallback((direction: undefined | string = undefined) => {
277276
if ($itemsWrapper && $itemsWrapper.current && $itemsWrapper.current.children) {
278277
const $children = $itemsWrapper.current.children;
279-
if ($elItemsWrapper === null) {
280-
return;
281-
}
282278
const containerHeight = $elItemsWrapper.current.offsetHeight;
283279
const containerScrollTop = $elItemsWrapper.current.scrollTop;
284280
if (!globalVariableCurrentFocus || !$children[globalVariableCurrentFocus]) {

webpack/umd.base.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ var config = (module.exports = {
112112
filename: outputFile,
113113
library: libraryName,
114114
libraryTarget: 'umd',
115+
globalObject: 'this',
115116
},
116117
externals: {
117118
react: 'react',

0 commit comments

Comments
 (0)