@clayui/autocomplete
Advanced tools
Comparing version 3.97.1 to 3.97.2
@@ -137,2 +137,3 @@ "use strict"; | ||
var menuRef = (0, _react.useRef)(null); | ||
var shouldIgnoreOpenMenuOnFocus = (0, _react.useRef)(false); | ||
var inputElementRef = ref || inputRef; | ||
@@ -175,3 +176,3 @@ var isLoading = Boolean(loadingState !== undefined && loadingState === 1); | ||
filterKey: 'value', | ||
itemContainer: function itemContainer(_ref3) { | ||
itemContainer: (0, _react.useCallback)(function (_ref3) { | ||
var _ref4, _children$props$textV; | ||
@@ -199,2 +200,3 @@ | ||
setValue(itemValue); | ||
shouldIgnoreOpenMenuOnFocus.current = true; | ||
(_inputElementRef$curr = inputElementRef.current) === null || _inputElementRef$curr === void 0 ? void 0 : _inputElementRef$curr.focus(); | ||
@@ -204,3 +206,3 @@ }, | ||
}); | ||
}, | ||
}, [value]), | ||
items: filteredItems, | ||
@@ -242,4 +244,15 @@ notFound: /*#__PURE__*/_react.default.createElement(_dropDown.default.Item, { | ||
}), | ||
navigationProps = _useNavigation.navigationProps; | ||
navigationProps = _useNavigation.navigationProps; // Resets `activeDescendant` when the menu is closed, this avoids a bug when | ||
// the `active` state is controlled and closes the menu with different | ||
// statements than what is expected internally. | ||
(0, _react.useEffect)(function () { | ||
if (!active && activeDescendant) { | ||
setActiveDescendant(''); | ||
} | ||
}, [active]); | ||
var onClose = (0, _react.useCallback)(function () { | ||
return setActive(false); | ||
}, []); | ||
var onPress = (0, _react.useCallback)(function () { | ||
@@ -285,2 +298,7 @@ if (menuRef.current && activeDescendant) { | ||
if (menuTrigger === 'focus' && items !== null) { | ||
if (shouldIgnoreOpenMenuOnFocus.current) { | ||
shouldIgnoreOpenMenuOnFocus.current = false; | ||
return; | ||
} | ||
setActive(true); | ||
@@ -372,6 +390,3 @@ } | ||
menuRef: menuRef, | ||
onClose: function onClose() { | ||
setActiveDescendant(''); | ||
setActive(false); | ||
}, | ||
onClose: onClose, | ||
portalRef: menuRef, | ||
@@ -378,0 +393,0 @@ suppress: [menuRef, inputElementRef], |
{ | ||
"name": "@clayui/autocomplete", | ||
"version": "3.97.1", | ||
"version": "3.97.2", | ||
"description": "ClayAutocomplete component", | ||
@@ -45,3 +45,3 @@ "license": "BSD-3-Clause", | ||
], | ||
"gitHead": "43c3c8808d305e16107e9218a07fedf807720fa9" | ||
"gitHead": "910d9c355595ec137dd768ebedf3221ea3be1ad2" | ||
} |
Sorry, the diff of this file is not supported yet
136641
27
2519