@snack-uikit/fields 0.42.1 → 0.42.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 +11 -0
- package/dist/cjs/components/FieldSelect/FieldSelectMultiple.js +0 -5
- package/dist/cjs/components/FieldSelect/FieldSelectSingle.js +1 -6
- package/dist/esm/components/FieldSelect/FieldSelectMultiple.js +1 -6
- package/dist/esm/components/FieldSelect/FieldSelectSingle.js +1 -6
- package/package.json +2 -2
- package/src/components/FieldSelect/FieldSelectMultiple.tsx +1 -7
- package/src/components/FieldSelect/FieldSelectSingle.tsx +1 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.42.2 (2025-05-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **PDS-2167:** field select behavior fixed when options are changed ([29c2cfe](https://github.com/cloud-ru-tech/snack-uikit/commit/29c2cfe43ecaceaaf0dba7b63b1c23b264df1aed))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.42.1 (2025-05-06)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -109,11 +109,6 @@ exports.FieldSelectMultiple = (0, react_1.forwardRef)((props, ref) => {
|
|
|
109
109
|
postfix,
|
|
110
110
|
disabled
|
|
111
111
|
});
|
|
112
|
-
(0, react_1.useEffect)(() => {
|
|
113
|
-
if (options.length === 0 && value && value.length > 0) {
|
|
114
|
-
setValue(undefined);
|
|
115
|
-
}
|
|
116
|
-
}, [options.length, setValue, value]);
|
|
117
112
|
(0, utils_1.useLayoutEffect)(() => {
|
|
118
113
|
setItems(_ref => {
|
|
119
114
|
let {
|
|
@@ -107,11 +107,6 @@ exports.FieldSelectSingle = (0, react_1.forwardRef)((props, ref) => {
|
|
|
107
107
|
postfix,
|
|
108
108
|
disabled
|
|
109
109
|
});
|
|
110
|
-
(0, react_1.useEffect)(() => {
|
|
111
|
-
if (options.length < 1 && Boolean(value)) {
|
|
112
|
-
setValue(undefined);
|
|
113
|
-
}
|
|
114
|
-
}, [options.length, setValue, value]);
|
|
115
110
|
(0, utils_1.useLayoutEffect)(() => {
|
|
116
111
|
setItems(_ref => {
|
|
117
112
|
let {
|
|
@@ -157,7 +152,7 @@ exports.FieldSelectSingle = (0, react_1.forwardRef)((props, ref) => {
|
|
|
157
152
|
} = (0, hooks_2.useButtons)({
|
|
158
153
|
readonly,
|
|
159
154
|
size,
|
|
160
|
-
showClearButton: showClearButton && !disabled && !readonly && value !== undefined,
|
|
155
|
+
showClearButton: showClearButton && !disabled && !readonly && value !== undefined && selectedItem !== undefined,
|
|
161
156
|
showCopyButton,
|
|
162
157
|
inputRef: localRef,
|
|
163
158
|
onClear,
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import cn from 'classnames';
|
|
14
14
|
import mergeRefs from 'merge-refs';
|
|
15
|
-
import { forwardRef,
|
|
15
|
+
import { forwardRef, useRef, useState } from 'react';
|
|
16
16
|
import { InputPrivate } from '@snack-uikit/input-private';
|
|
17
17
|
import { Droplist } from '@snack-uikit/list';
|
|
18
18
|
import { Tag } from '@snack-uikit/tag';
|
|
@@ -47,11 +47,6 @@ export const FieldSelectMultiple = forwardRef((props, ref) => {
|
|
|
47
47
|
resetSearchOnOptionSelection }));
|
|
48
48
|
const prefixSettings = usePrefix({ prefix, disabled });
|
|
49
49
|
const postfixSettings = usePostfix({ postfix, disabled });
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (options.length === 0 && value && value.length > 0) {
|
|
52
|
-
setValue(undefined);
|
|
53
|
-
}
|
|
54
|
-
}, [options.length, setValue, value]);
|
|
55
50
|
useLayoutEffect(() => {
|
|
56
51
|
setItems(({ selectedItems }) => updateMultipleItems({ options, value, selectedItems }));
|
|
57
52
|
}, [options, value]);
|
|
@@ -43,11 +43,6 @@ export const FieldSelectSingle = forwardRef((props, ref) => {
|
|
|
43
43
|
const prevSelectedItem = useRef(selectedItem);
|
|
44
44
|
const prefixSettings = usePrefix({ prefix, disabled });
|
|
45
45
|
const postfixSettings = usePostfix({ postfix, disabled });
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (options.length < 1 && Boolean(value)) {
|
|
48
|
-
setValue(undefined);
|
|
49
|
-
}
|
|
50
|
-
}, [options.length, setValue, value]);
|
|
51
46
|
useLayoutEffect(() => {
|
|
52
47
|
setItems(({ selectedItem }) => updateItems({ options, value, selectedItem }));
|
|
53
48
|
}, [options, value]);
|
|
@@ -75,7 +70,7 @@ export const FieldSelectSingle = forwardRef((props, ref) => {
|
|
|
75
70
|
const { postfixButtons, inputKeyDownNavigationHandler, buttonsRefs } = useButtons({
|
|
76
71
|
readonly,
|
|
77
72
|
size,
|
|
78
|
-
showClearButton: showClearButton && !disabled && !readonly && value !== undefined,
|
|
73
|
+
showClearButton: showClearButton && !disabled && !readonly && value !== undefined && selectedItem !== undefined,
|
|
79
74
|
showCopyButton,
|
|
80
75
|
inputRef: localRef,
|
|
81
76
|
onClear,
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.42.
|
|
7
|
+
"version": "0.42.2",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@snack-uikit/locale": "*"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "ab82d31b168bac141d19f6b7d43b3f1888387038"
|
|
69
69
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cn from 'classnames';
|
|
2
2
|
import mergeRefs from 'merge-refs';
|
|
3
|
-
import { FocusEvent, forwardRef, KeyboardEvent, KeyboardEventHandler,
|
|
3
|
+
import { FocusEvent, forwardRef, KeyboardEvent, KeyboardEventHandler, useRef, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { InputPrivate } from '@snack-uikit/input-private';
|
|
6
6
|
import { BaseItemProps, Droplist, ItemProps, SelectionSingleValueType } from '@snack-uikit/list';
|
|
@@ -82,12 +82,6 @@ export const FieldSelectMultiple = forwardRef<HTMLInputElement, FieldSelectMulti
|
|
|
82
82
|
const prefixSettings = usePrefix({ prefix, disabled });
|
|
83
83
|
const postfixSettings = usePostfix({ postfix, disabled });
|
|
84
84
|
|
|
85
|
-
useEffect(() => {
|
|
86
|
-
if (options.length === 0 && value && value.length > 0) {
|
|
87
|
-
setValue(undefined);
|
|
88
|
-
}
|
|
89
|
-
}, [options.length, setValue, value]);
|
|
90
|
-
|
|
91
85
|
useLayoutEffect(() => {
|
|
92
86
|
setItems(({ selectedItems }) => updateMultipleItems({ options, value, selectedItems }));
|
|
93
87
|
}, [options, value]);
|
|
@@ -88,12 +88,6 @@ export const FieldSelectSingle = forwardRef<HTMLInputElement, FieldSelectSingleP
|
|
|
88
88
|
const prefixSettings = usePrefix({ prefix, disabled });
|
|
89
89
|
const postfixSettings = usePostfix({ postfix, disabled });
|
|
90
90
|
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
if (options.length < 1 && Boolean(value)) {
|
|
93
|
-
setValue(undefined);
|
|
94
|
-
}
|
|
95
|
-
}, [options.length, setValue, value]);
|
|
96
|
-
|
|
97
91
|
useLayoutEffect(() => {
|
|
98
92
|
setItems(({ selectedItem }) => updateItems({ options, value, selectedItem }));
|
|
99
93
|
}, [options, value]);
|
|
@@ -128,7 +122,7 @@ export const FieldSelectSingle = forwardRef<HTMLInputElement, FieldSelectSingleP
|
|
|
128
122
|
const { postfixButtons, inputKeyDownNavigationHandler, buttonsRefs } = useButtons({
|
|
129
123
|
readonly,
|
|
130
124
|
size,
|
|
131
|
-
showClearButton: showClearButton && !disabled && !readonly && value !== undefined,
|
|
125
|
+
showClearButton: showClearButton && !disabled && !readonly && value !== undefined && selectedItem !== undefined,
|
|
132
126
|
showCopyButton,
|
|
133
127
|
inputRef: localRef,
|
|
134
128
|
onClear,
|