@wallarm-org/design-system 0.29.0 → 0.29.1-rc-feature-AS-882.1

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.
@@ -51,6 +51,7 @@ const FilterInputDateValueMenu = ({ open, onSelect, onRangeSelect, onOpenChange,
51
51
  children: /*#__PURE__*/ jsx(DropdownMenuContent, {
52
52
  ref: menuRef,
53
53
  className: cn('w-fit', className),
54
+ "data-filter-input-menu": "",
54
55
  onKeyDown: (e)=>{
55
56
  if ('Escape' === e.key) {
56
57
  e.preventDefault();
@@ -109,6 +109,7 @@ const FilterInputFieldMenu = ({ fields, filterText = '', onSelect, open = false,
109
109
  ref: menuRef,
110
110
  className: cn('w-[300px] max-h-[430px]', className),
111
111
  "data-slot": "filter-input-field-menu",
112
+ "data-filter-input-menu": "",
112
113
  children: [
113
114
  !filterText && showRecent && /*#__PURE__*/ jsx(RecentSection, {
114
115
  conditions: limitedRecentConditions,
@@ -56,6 +56,7 @@ const FilterInputOperatorMenu = ({ fieldType, operators, onSelect, open = false,
56
56
  children: /*#__PURE__*/ jsxs(DropdownMenuContent, {
57
57
  ref: menuRef,
58
58
  className: cn('w-256 max-h-[430px]', className),
59
+ "data-filter-input-menu": "",
59
60
  children: [
60
61
  filteredGroups.length > 0 ? filteredGroups.map((group, groupIdx)=>/*#__PURE__*/ jsxs(Fragment, {
61
62
  children: [
@@ -54,6 +54,7 @@ const FilterInputValueMenu = ({ values, onSelect, onCommit, open = false, onOpen
54
54
  ref: menuRef,
55
55
  className: cn(widthClass, 'max-h-[430px]', className),
56
56
  style: widthStyle,
57
+ "data-filter-input-menu": "",
57
58
  children: [
58
59
  displayValues.length > 0 ? /*#__PURE__*/ jsx(DropdownMenuGroup, {
59
60
  children: displayValues.map((option)=>/*#__PURE__*/ jsx(ValueMenuItem, {
@@ -1,7 +1,7 @@
1
1
  import { useCallback, useRef, useState } from "react";
2
2
  import { flushSync } from "react-dom";
3
3
  import { useDateRange } from "../../FilterInputMenu/FilterInputDateValueMenu/hooks.js";
4
- import { applyAcceptChar, chipIdToConditionIndex } from "../../lib/index.js";
4
+ import { applyAcceptChar, chipIdToConditionIndex, isMenuRelated } from "../../lib/index.js";
5
5
  import { deriveAutocompleteValues } from "./deriveAutocompleteValues.js";
6
6
  import { useChipEditing } from "./useChipEditing.js";
7
7
  import { useFocusManagement } from "./useFocusManagement.js";
@@ -61,11 +61,14 @@ const useFilterInputAutocomplete = ({ fields, conditions, chips, upsertCondition
61
61
  flushSync(doReset);
62
62
  setMenuState('field');
63
63
  } else doReset();
64
- inputRef.current?.focus();
64
+ const active = document.activeElement;
65
+ const stayedInside = !active || active === document.body || containerRef.current?.contains(active) || isMenuRelated(active);
66
+ if (stayedInside) inputRef.current?.focus();
65
67
  }, [
66
68
  editing,
67
69
  dateRange,
68
70
  inputRef,
71
+ containerRef,
69
72
  resetMenuOffset
70
73
  ]);
71
74
  const selectedFieldRef = useRef(selectedField);
@@ -14,12 +14,15 @@ const useFocusManagement = ({ menuState, isFocused, conditionsLength, inputText,
14
14
  setIsFocused(false);
15
15
  const committed = blurCommitRef.current?.() || commitBuildingOnBlur();
16
16
  if (!committed) resetState();
17
+ related?.focus();
18
+ if (document.activeElement === inputRef.current) inputRef.current?.blur();
17
19
  }, [
18
20
  containerRef,
19
21
  blurCommitRef,
20
22
  commitBuildingOnBlur,
21
23
  resetState,
22
- setIsFocused
24
+ setIsFocused,
25
+ inputRef
23
26
  ]);
24
27
  const prevFocusedRef = useRef(false);
25
28
  useEffect(()=>{
@@ -37,12 +40,17 @@ const useFocusManagement = ({ menuState, isFocused, conditionsLength, inputText,
37
40
  ]);
38
41
  useEffect(()=>{
39
42
  if ('closed' === menuState) return;
43
+ if (!isFocused) return;
40
44
  let outerRaf = 0;
41
45
  let innerRaf = 0;
42
46
  outerRaf = requestAnimationFrame(()=>{
43
47
  innerRaf = requestAnimationFrame(()=>{
48
+ const container = containerRef.current;
49
+ if (!container) return;
50
+ const active = document.activeElement;
51
+ if (active && !container.contains(active) && !isMenuRelated(active)) return;
44
52
  if (editingSegment) {
45
- const segmentInput = containerRef.current?.querySelector(`[data-slot="segment-${editingSegment}"] input`);
53
+ const segmentInput = container.querySelector(`[data-slot="segment-${editingSegment}"] input`);
46
54
  if (segmentInput && document.activeElement !== segmentInput) {
47
55
  segmentInput.focus();
48
56
  segmentInput.select();
@@ -56,6 +64,7 @@ const useFocusManagement = ({ menuState, isFocused, conditionsLength, inputText,
56
64
  };
57
65
  }, [
58
66
  menuState,
67
+ isFocused,
59
68
  inputRef,
60
69
  editingSegment,
61
70
  containerRef
@@ -1,4 +1,12 @@
1
- /** Check if an element belongs to a menu/portal overlay (dropdown, date-picker, etc.) */
1
+ /**
2
+ * Check if an element belongs to a FilterInput-owned menu/portal overlay.
3
+ *
4
+ * Menus are marked with `data-filter-input-menu` on their `DropdownMenuContent`
5
+ * root. Generic Ark UI selectors (`[role="menu"]`, `[data-part="content"]`,
6
+ * `[data-scope="date-picker"]`) intentionally DO NOT match — otherwise blur
7
+ * handlers mistake unrelated page popups (tenant switcher, other dropdowns)
8
+ * for FilterInput's own menu and refuse to close. See AS-882.
9
+ */
2
10
  export declare const isMenuRelated: (el: HTMLElement | null) => boolean;
3
11
  /**
4
12
  * Build a DOMRect-compatible object anchored vertically to the container
@@ -1,4 +1,4 @@
1
- const isMenuRelated = (el)=>!!(el?.closest('[role="menu"]') || el?.closest('[data-scope="menu"]') || el?.closest('[data-scope="date-picker"]') || el?.closest('[data-part="content"]'));
1
+ const isMenuRelated = (el)=>!!el?.closest('[data-filter-input-menu]');
2
2
  const buildContainerAnchoredRect = (containerRect, anchorLeft, anchorRight = containerRect.right)=>({
3
3
  x: anchorLeft,
4
4
  y: containerRect.top,
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.28.0",
3
- "generatedAt": "2026-04-24T12:14:20.763Z",
2
+ "version": "0.29.0",
3
+ "generatedAt": "2026-04-24T15:27:31.236Z",
4
4
  "components": [
5
5
  {
6
6
  "name": "Alert",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wallarm-org/design-system",
3
- "version": "0.29.0",
3
+ "version": "0.29.1-rc-feature-AS-882.1",
4
4
  "description": "Core design system library with React components and Storybook documentation",
5
5
  "publishConfig": {
6
6
  "access": "public",