@snack-uikit/chips 0.14.0 → 0.14.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 0.14.2 (2024-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **FF-0000:** add forgotten ([96e1334](https://github.com/cloud-ru-tech/snack-uikit/commit/96e13348e646f581a97cabe873cdfe02c5a96658))
12
+
13
+
14
+
15
+
16
+
17
+ ## 0.14.1 (2024-05-13)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **FF-0000:** fix keyboard control ([4fabf88](https://github.com/cloud-ru-tech/snack-uikit/commit/4fabf886d367c8f83648eccae36a7e2d500192da))
23
+
24
+
25
+
26
+
27
+
6
28
  # 0.14.0 (2024-05-08)
7
29
 
8
30
 
@@ -59,12 +59,17 @@ export function ChipChoiceMultiple(_a) {
59
59
  const items = useMemo(() => transformOptionsToItems(result, contentRender), [contentRender, result]);
60
60
  const clearValue = () => setValue([]);
61
61
  const chipRef = useRef(null);
62
+ const listRef = useRef(null);
62
63
  const handleSelectionChange = useCallback((newValue) => {
64
+ var _a;
63
65
  if (newValue !== undefined) {
64
66
  setValue(newValue);
67
+ if (searchValue) {
68
+ (_a = listRef.current) === null || _a === void 0 ? void 0 : _a.focus();
69
+ }
65
70
  setSearchValue('');
66
71
  }
67
- }, [setValue]);
72
+ }, [searchValue, setValue]);
68
73
  useEffect(() => {
69
74
  if (searchValue && !open) {
70
75
  setSearchValue('');
@@ -74,7 +79,7 @@ export function ChipChoiceMultiple(_a) {
74
79
  value,
75
80
  onChange: handleSelectionChange,
76
81
  mode: 'multiple',
77
- }, trigger: 'clickAndFocusVisible', placement: 'bottom-start', widthStrategy: 'gte', size: DROPLIST_SIZE_MAP[size], "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, open: open, triggerElemRef: chipRef, onOpenChange: open => {
82
+ }, trigger: 'clickAndFocusVisible', placement: 'bottom-start', widthStrategy: 'gte', listRef: listRef, size: DROPLIST_SIZE_MAP[size], "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, open: open, onOpenChange: open => {
78
83
  if (!open) {
79
84
  setSearchValue('');
80
85
  }
@@ -66,7 +66,7 @@ export function ChipChoiceSingle(_a) {
66
66
  value,
67
67
  onChange: handleSelectionChange,
68
68
  mode: 'single',
69
- }, "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, size: DROPLIST_SIZE_MAP[size], trigger: 'click', placement: 'bottom-start', className: dropDownClassName, widthStrategy: 'gte', open: open, triggerElemRef: chipRef, onOpenChange: open => {
69
+ }, "data-test-id": CHIP_CHOICE_TEST_IDS.droplist, size: DROPLIST_SIZE_MAP[size], trigger: 'click', placement: 'bottom-start', className: dropDownClassName, closeDroplistOnItemClick: true, widthStrategy: 'gte', open: open, onOpenChange: open => {
70
70
  if (!open) {
71
71
  setSearchValue('');
72
72
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "title": "Chips",
7
- "version": "0.14.0",
7
+ "version": "0.14.2",
8
8
  "sideEffects": [
9
9
  "*.css",
10
10
  "*.woff",
@@ -36,7 +36,7 @@
36
36
  "@snack-uikit/calendar": "0.7.9",
37
37
  "@snack-uikit/dropdown": "0.2.2",
38
38
  "@snack-uikit/icons": "0.21.0",
39
- "@snack-uikit/list": "0.12.0",
39
+ "@snack-uikit/list": "0.13.0",
40
40
  "@snack-uikit/loaders": "0.5.2",
41
41
  "@snack-uikit/utils": "3.3.0",
42
42
  "classnames": "2.3.2",
@@ -50,5 +50,5 @@
50
50
  "peerDependencies": {
51
51
  "@snack-uikit/locale": "*"
52
52
  },
53
- "gitHead": "a308f550fb12d114a27d9b7d6804c212a316a09d"
53
+ "gitHead": "58d2de0677c973ff4510861699d6fc19b8912a44"
54
54
  }
@@ -90,15 +90,19 @@ export function ChipChoiceMultiple<T extends ContentRenderProps = ContentRenderP
90
90
 
91
91
  const clearValue = () => setValue([]);
92
92
  const chipRef = useRef<HTMLDivElement>(null);
93
+ const listRef = useRef<HTMLElement>(null);
93
94
 
94
95
  const handleSelectionChange = useCallback(
95
96
  (newValue?: SelectionSingleValueType) => {
96
97
  if (newValue !== undefined) {
97
98
  setValue(newValue);
99
+ if (searchValue) {
100
+ listRef.current?.focus();
101
+ }
98
102
  setSearchValue('');
99
103
  }
100
104
  },
101
- [setValue],
105
+ [searchValue, setValue],
102
106
  );
103
107
 
104
108
  useEffect(() => {
@@ -119,10 +123,10 @@ export function ChipChoiceMultiple<T extends ContentRenderProps = ContentRenderP
119
123
  trigger='clickAndFocusVisible'
120
124
  placement='bottom-start'
121
125
  widthStrategy='gte'
126
+ listRef={listRef}
122
127
  size={DROPLIST_SIZE_MAP[size]}
123
128
  data-test-id={CHIP_CHOICE_TEST_IDS.droplist}
124
129
  open={open}
125
- triggerElemRef={chipRef}
126
130
  onOpenChange={open => {
127
131
  if (!open) {
128
132
  setSearchValue('');
@@ -108,9 +108,9 @@ export function ChipChoiceSingle<T extends ContentRenderProps = ContentRenderPro
108
108
  trigger='click'
109
109
  placement='bottom-start'
110
110
  className={dropDownClassName}
111
+ closeDroplistOnItemClick
111
112
  widthStrategy='gte'
112
113
  open={open}
113
- triggerElemRef={chipRef}
114
114
  onOpenChange={open => {
115
115
  if (!open) {
116
116
  setSearchValue('');