@testing-library/user-event 12.8.2 → 12.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/tab.js +2 -1
- package/dist/utils.js +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -695,6 +695,7 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
695
695
|
</tr>
|
|
696
696
|
<tr>
|
|
697
697
|
<td align="center"><a href="https://github.com/jKatt"><img src="https://avatars.githubusercontent.com/u/5550790?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jan Kattelans</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jKatt" title="Code">💻</a></td>
|
|
698
|
+
<td align="center"><a href="https://github.com/schoeneu"><img src="https://avatars.githubusercontent.com/u/3261341?v=4?s=100" width="100px;" alt=""/><br /><sub><b>schoeneu</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Aschoeneu" title="Bug reports">🐛</a></td>
|
|
698
699
|
</tr>
|
|
699
700
|
</table>
|
|
700
701
|
|
package/dist/tab.js
CHANGED
|
@@ -38,7 +38,8 @@ function tab({
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const focusableElements = focusTrap.querySelectorAll(_utils.FOCUSABLE_SELECTOR);
|
|
41
|
-
const enabledElements = [...focusableElements].filter(el => el === previousElement || el.getAttribute('tabindex') !== '-1' && !el.disabled
|
|
41
|
+
const enabledElements = [...focusableElements].filter(el => el === previousElement || el.getAttribute('tabindex') !== '-1' && !el.disabled && // Hidden elements are not tabable
|
|
42
|
+
(0, _utils.isVisible)(el));
|
|
42
43
|
if (enabledElements.length === 0) return;
|
|
43
44
|
const orderedElements = enabledElements.map((el, idx) => ({
|
|
44
45
|
el,
|
package/dist/utils.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.getValue = getValue;
|
|
|
18
18
|
exports.getSelectionRange = getSelectionRange;
|
|
19
19
|
exports.isContentEditable = isContentEditable;
|
|
20
20
|
exports.isInstanceOfElement = isInstanceOfElement;
|
|
21
|
+
exports.isVisible = isVisible;
|
|
21
22
|
exports.FOCUSABLE_SELECTOR = void 0;
|
|
22
23
|
|
|
23
24
|
var _dom = require("@testing-library/dom");
|
|
@@ -278,6 +279,20 @@ function isClickableInput(element) {
|
|
|
278
279
|
return element.tagName === 'BUTTON' || isInstanceOfElement(element, 'HTMLInputElement') && CLICKABLE_INPUT_TYPES.includes(element.type);
|
|
279
280
|
}
|
|
280
281
|
|
|
282
|
+
function isVisible(element) {
|
|
283
|
+
const getComputedStyle = (0, _helpers.getWindowFromNode)(element).getComputedStyle;
|
|
284
|
+
|
|
285
|
+
for (; element && element.ownerDocument; element = element.parentNode) {
|
|
286
|
+
const display = getComputedStyle(element).display;
|
|
287
|
+
|
|
288
|
+
if (display === 'none') {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return true;
|
|
294
|
+
}
|
|
295
|
+
|
|
281
296
|
function eventWrapper(cb) {
|
|
282
297
|
let result;
|
|
283
298
|
(0, _dom.getConfig)().eventWrapper(() => {
|