Skip to content

Commit f726696

Browse files
author
glortho
committed
update ignores
1 parent e5ffe89 commit f726696

6 files changed

+26
-6
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ build/Release
2525
# Dependency directory
2626
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
2727
node_modules
28+
29+
dist
30+
es

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

dist/event_handlers.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr
4444
function _onClick(_ref) {
4545
var target = _ref.target;
4646

47-
_store2.default.activate([].concat(_toConsumableArray(_store2.default.getInstances())).reduce(_dom_helpers2.default.findContainerNodes(target), []).sort(_dom_helpers2.default.sortByDOMPosition).map(function (item) {
48-
return item.instance;
49-
}));
47+
// only reshuffle order if the click target is no longer in the
48+
// DOM. See https://github.com/glortho/react-keydown/issues/55
49+
if (_dom_helpers2.default.isAttached(target)) {
50+
_store2.default.activate([].concat(_toConsumableArray(_store2.default.getInstances())).reduce(_dom_helpers2.default.findContainerNodes(target), []).sort(_dom_helpers2.default.sortByDOMPosition).map(function (item) {
51+
return item.instance;
52+
}));
53+
}
5054
}
5155

5256
/**

dist/lib/dom_helpers.js

+4
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ function findContainerNodes(target) {
7272
};
7373
}
7474

75+
function isAttached(node) {
76+
return node && node !== document && node.parentNode;
77+
}
78+
7579
/**
7680
* sortByDOMPosition: Called by our click handler to sort a list of instances
7781
* according to least -> most nested. This is so that if multiple keybound

es/event_handlers.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ import store from './store';
2424
export function _onClick(_ref) {
2525
var target = _ref.target;
2626

27-
store.activate([].concat(_toConsumableArray(store.getInstances())).reduce(domHelpers.findContainerNodes(target), []).sort(domHelpers.sortByDOMPosition).map(function (item) {
28-
return item.instance;
29-
}));
27+
// only reshuffle order if the click target is no longer in the
28+
// DOM. See https://github.com/glortho/react-keydown/issues/55
29+
if (domHelpers.isAttached(target)) {
30+
store.activate([].concat(_toConsumableArray(store.getInstances())).reduce(domHelpers.findContainerNodes(target), []).sort(domHelpers.sortByDOMPosition).map(function (item) {
31+
return item.instance;
32+
}));
33+
}
3034
}
3135

3236
/**

es/lib/dom_helpers.js

+4
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ function findContainerNodes(target) {
6262
};
6363
}
6464

65+
function isAttached(node) {
66+
return node && node !== document && node.parentNode;
67+
}
68+
6569
/**
6670
* sortByDOMPosition: Called by our click handler to sort a list of instances
6771
* according to least -> most nested. This is so that if multiple keybound

0 commit comments

Comments
 (0)