@clayui/shared
Advanced tools
Comparing version 3.103.1 to 3.104.0
@@ -65,9 +65,25 @@ "use strict"; | ||
var element = item instanceof HTMLElement ? item : document.getElementById(String(item)); | ||
onNavigate(item, index); | ||
if (onNavigate) { | ||
onNavigate(item, index); | ||
} | ||
if (collection !== null && collection !== void 0 && collection.virtualize) { | ||
var isEnd = collection.UNSAFE_virtualizer.options.count - 1 === index; | ||
var isStart = index === 0; | ||
collection.UNSAFE_virtualizer.scrollToIndex(index, { | ||
align: 'auto', | ||
behavior: 'smooth' | ||
behavior: isStart || isEnd ? 'auto' : 'smooth' | ||
}); | ||
if (!onNavigate && !element) { | ||
setTimeout(function () { | ||
var nextFocus = containerRef.current.querySelector("[data-focus=\"".concat(item, "\"]")); | ||
if (nextFocus) { | ||
nextFocus.focus(); | ||
} | ||
}, 20); | ||
} | ||
return; | ||
@@ -112,8 +128,18 @@ } | ||
if (collection) { | ||
var _key = orientation === 'vertical' ? _Keys.Keys.Up : _Keys.Keys.Left; | ||
if (collection && typeof active === 'string') { | ||
position = items.indexOf(active); | ||
} else { | ||
} else if (collection) { | ||
var activeElement = document.activeElement; | ||
position = items.indexOf(activeElement); | ||
var focusKey = activeElement.getAttribute('data-focus'); | ||
position = items.indexOf(focusKey); | ||
if (position === -1) { | ||
_item = event.key === _key ? collection.getLastItem().key : collection.getFirstItem().key; | ||
} | ||
} else { | ||
var _activeElement = document.activeElement; | ||
position = items.indexOf(_activeElement); | ||
if (typeof active === 'string') { | ||
@@ -130,4 +156,2 @@ position = items.findIndex(function (element) { | ||
var _key = orientation === 'vertical' ? _Keys.Keys.Up : _Keys.Keys.Left; | ||
_item = items[event.key === _key ? position - 1 : position + 1]; | ||
@@ -205,3 +229,3 @@ | ||
if (onNavigate) { | ||
if (onNavigate || !element) { | ||
accessibilityFocus(_item, items); | ||
@@ -208,0 +232,0 @@ } else { |
{ | ||
"name": "@clayui/shared", | ||
"version": "3.103.1", | ||
"version": "3.104.0", | ||
"description": "ClayShared component", | ||
@@ -45,3 +45,3 @@ "license": "BSD-3-Clause", | ||
], | ||
"gitHead": "cd95e9b9561858fb6832a524a2a0b0304a500d3f" | ||
"gitHead": "44f72fac40321954bf46e8f61b163ff71ae04403" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
182068
5121