hi-tm 0.6.9 → 0.7.0
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.
|
@@ -137,6 +137,8 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
137
137
|
const scrollContainerRef = (0, react_1.useRef)(null);
|
|
138
138
|
// Prevent scroll jumping by maintaining position during keyboard navigation
|
|
139
139
|
const handleKeyboardNavigation = (0, react_1.useCallback)((direction) => {
|
|
140
|
+
// Set user interaction flag to prevent external sync
|
|
141
|
+
setIsUserInteracting(true);
|
|
140
142
|
// Don't save scroll position - just update the highlighted index
|
|
141
143
|
if (direction === 'up') {
|
|
142
144
|
highlightedIndexRef.current = Math.max(0, highlightedIndexRef.current - 1);
|
|
@@ -146,6 +148,10 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
146
148
|
}
|
|
147
149
|
// Force re-render of dropdown options only
|
|
148
150
|
setForceUpdate((prev) => prev + 1);
|
|
151
|
+
// Reset the flag after a delay
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
setIsUserInteracting(false);
|
|
154
|
+
}, 1000);
|
|
149
155
|
}, [filteredOptions.length]);
|
|
150
156
|
// Sync external value prop with internal selectedValues state
|
|
151
157
|
(0, react_1.useEffect)(() => {
|
|
@@ -188,7 +194,7 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
188
194
|
setSelectedValues(singleItem);
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
|
-
}, [value, isMultiSelect,
|
|
197
|
+
}, [value, isMultiSelect, isUserInteracting]);
|
|
192
198
|
// Sync options into filtered list when not searching
|
|
193
199
|
(0, react_1.useEffect)(() => {
|
|
194
200
|
if (!hasSearched) {
|
|
@@ -248,6 +254,8 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
248
254
|
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
249
255
|
if (isDisabled)
|
|
250
256
|
return;
|
|
257
|
+
// Set user interaction flag for all keyboard events
|
|
258
|
+
setIsUserInteracting(true);
|
|
251
259
|
switch (e.key) {
|
|
252
260
|
case 'Enter':
|
|
253
261
|
e.preventDefault();
|
|
@@ -289,6 +297,10 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
289
297
|
}
|
|
290
298
|
break;
|
|
291
299
|
}
|
|
300
|
+
// Reset the flag after a delay
|
|
301
|
+
setTimeout(() => {
|
|
302
|
+
setIsUserInteracting(false);
|
|
303
|
+
}, 1000);
|
|
292
304
|
}, [
|
|
293
305
|
isDisabled,
|
|
294
306
|
isOpen,
|
|
@@ -332,10 +344,15 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
332
344
|
}, [inputValue, isCreatable, onCreateOption]);
|
|
333
345
|
const toggleDropdown = (0, react_1.useCallback)(() => {
|
|
334
346
|
if (!isDisabled) {
|
|
347
|
+
setIsUserInteracting(true);
|
|
335
348
|
setIsOpen((prev) => !prev);
|
|
336
349
|
if (!isOpen && inputRef.current) {
|
|
337
350
|
inputRef.current.focus();
|
|
338
351
|
}
|
|
352
|
+
// Reset the flag after a delay
|
|
353
|
+
setTimeout(() => {
|
|
354
|
+
setIsUserInteracting(false);
|
|
355
|
+
}, 1000);
|
|
339
356
|
}
|
|
340
357
|
}, [isDisabled, isOpen]);
|
|
341
358
|
const clearValue = (0, react_1.useCallback)((e, option) => {
|
|
@@ -345,6 +362,8 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
345
362
|
emitSelection(next);
|
|
346
363
|
}, [selectedValues, deriveValue, emitSelection]);
|
|
347
364
|
const selectOption = (0, react_1.useCallback)((option) => {
|
|
365
|
+
// Set user interaction flag to prevent external sync
|
|
366
|
+
setIsUserInteracting(true);
|
|
348
367
|
if (isMultiSelect) {
|
|
349
368
|
const next = [...selectedValues];
|
|
350
369
|
if (!next.some((val) => deriveValue(val) === deriveValue(option))) {
|
|
@@ -365,6 +384,10 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
365
384
|
setIsOpen(false);
|
|
366
385
|
setHasSearched(false);
|
|
367
386
|
}
|
|
387
|
+
// Reset the flag after a delay
|
|
388
|
+
setTimeout(() => {
|
|
389
|
+
setIsUserInteracting(false);
|
|
390
|
+
}, 1000);
|
|
368
391
|
}, [isMultiSelect, selectedValues, deriveValue, emitSelection]);
|
|
369
392
|
const showLoading = isLoading || internalLoading;
|
|
370
393
|
const handleAddIconClick = (0, react_1.useCallback)((e) => {
|