@wallarm-org/design-system 0.40.0-rc-feature-AS-982.2 → 0.40.0-rc-feature-AS-982.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/dist/components/FilterInput/FilterInputField/hooks/useSegmentEditKeyboard.d.ts +2 -1
- package/dist/components/FilterInput/FilterInputMenu/hooks/useKeyboardNav.js +0 -1
- package/dist/components/FilterInput/hooks/useFilterInputAutocomplete/useFocusManagement.js +37 -1
- package/dist/metadata/components.json +1 -1
- package/package.json +1 -1
|
@@ -24,7 +24,8 @@ interface UseSegmentEditKeyboardOptions {
|
|
|
24
24
|
* attribute) and, if the attribute is empty with no operator/value left,
|
|
25
25
|
* removes the chip.
|
|
26
26
|
* - Enter commits the typed text via the segment-specific commit callback.
|
|
27
|
-
* - ArrowDown
|
|
27
|
+
* - ArrowDown is intercepted (preventDefault) but focus stays on the input —
|
|
28
|
+
* highlight navigation runs through useKeyboardNav's window-capture listener.
|
|
28
29
|
*
|
|
29
30
|
* Returns the keydown + blur handlers fed to `EditingProvider` so every
|
|
30
31
|
* segment input dispatches through the same logic.
|
|
@@ -154,7 +154,6 @@ const useKeyboardNav = ({ items, open, onSelect, onClose, onArrowRight, onPendin
|
|
|
154
154
|
e.preventDefault();
|
|
155
155
|
e.stopPropagation();
|
|
156
156
|
navigate('ArrowDown' === e.key ? 1 : -1);
|
|
157
|
-
stateRef.current.menuRef?.current?.focus();
|
|
158
157
|
break;
|
|
159
158
|
case 'Enter':
|
|
160
159
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { SEGMENT_VARIANT } from "../../FilterInputField/FilterInputChip/index.js";
|
|
3
3
|
import { isMenuRelated, nextBuildingMenu } from "../../lib/index.js";
|
|
4
4
|
const useFocusManagement = ({ menuState, isFocused, conditionsLength, inputText, selectedField, selectedOperator, containerRef, inputRef, editingSegment, segmentAttributeInputRef, segmentOperatorInputRef, segmentValueInputRef, blurCommitRef, commitBuildingOnBlur, hasIncompleteBuilding, setIsFocused, setMenuState, resetMenuOffset, resetState })=>{
|
|
@@ -102,6 +102,42 @@ const useFocusManagement = ({ menuState, isFocused, conditionsLength, inputText,
|
|
|
102
102
|
segmentOperatorInputRef,
|
|
103
103
|
segmentValueInputRef
|
|
104
104
|
]);
|
|
105
|
+
const segmentInputRefsMap = useMemo(()=>({
|
|
106
|
+
[SEGMENT_VARIANT.attribute]: segmentAttributeInputRef,
|
|
107
|
+
[SEGMENT_VARIANT.operator]: segmentOperatorInputRef,
|
|
108
|
+
[SEGMENT_VARIANT.value]: segmentValueInputRef
|
|
109
|
+
}), [
|
|
110
|
+
segmentAttributeInputRef,
|
|
111
|
+
segmentOperatorInputRef,
|
|
112
|
+
segmentValueInputRef
|
|
113
|
+
]);
|
|
114
|
+
useEffect(()=>{
|
|
115
|
+
if ('closed' === menuState) return;
|
|
116
|
+
if (!isFocused) return;
|
|
117
|
+
const handleFocusIn = (e)=>{
|
|
118
|
+
const targetEl = e.target;
|
|
119
|
+
if (!targetEl) return;
|
|
120
|
+
const menu = targetEl.closest('[data-filter-input-menu]');
|
|
121
|
+
if (!menu) return;
|
|
122
|
+
if (menu.querySelector('[data-scope="date-picker"]')) return;
|
|
123
|
+
const tag = targetEl.tagName;
|
|
124
|
+
if ('BUTTON' === tag || 'INPUT' === tag || 'TEXTAREA' === tag || 'SELECT' === tag) return;
|
|
125
|
+
const dest = editingSegment ? segmentInputRefsMap[editingSegment]?.current : inputRef.current;
|
|
126
|
+
if (!dest) return;
|
|
127
|
+
if (document.activeElement === dest) return;
|
|
128
|
+
dest.focus({
|
|
129
|
+
preventScroll: true
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
document.addEventListener('focusin', handleFocusIn);
|
|
133
|
+
return ()=>document.removeEventListener('focusin', handleFocusIn);
|
|
134
|
+
}, [
|
|
135
|
+
menuState,
|
|
136
|
+
isFocused,
|
|
137
|
+
editingSegment,
|
|
138
|
+
inputRef,
|
|
139
|
+
segmentInputRefsMap
|
|
140
|
+
]);
|
|
105
141
|
return {
|
|
106
142
|
handleFocus,
|
|
107
143
|
handleBlur
|
package/package.json
CHANGED