hi-tm 0.7.0 → 0.7.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.
|
@@ -155,12 +155,17 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
155
155
|
}, [filteredOptions.length]);
|
|
156
156
|
// Sync external value prop with internal selectedValues state
|
|
157
157
|
(0, react_1.useEffect)(() => {
|
|
158
|
+
console.log('=== useEffect sync triggered ===');
|
|
159
|
+
console.log('isUserInteracting:', isUserInteracting);
|
|
160
|
+
console.log('external value:', value);
|
|
161
|
+
console.log('current selectedValues:', selectedValues);
|
|
162
|
+
console.log('isMultiSelect:', isMultiSelect);
|
|
158
163
|
// Don't sync if user is actively interacting with the component
|
|
159
164
|
if (isUserInteracting) {
|
|
160
165
|
console.log('Skipping sync - user is interacting');
|
|
161
166
|
return;
|
|
162
167
|
}
|
|
163
|
-
console.log('
|
|
168
|
+
console.log('Proceeding with sync...');
|
|
164
169
|
// Only sync if the external value is actually different from current selectedValues
|
|
165
170
|
const currentValues = selectedValues;
|
|
166
171
|
const externalValue = value;
|
|
@@ -194,6 +199,7 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
194
199
|
setSelectedValues(singleItem);
|
|
195
200
|
}
|
|
196
201
|
}
|
|
202
|
+
console.log('=== useEffect sync completed ===');
|
|
197
203
|
}, [value, isMultiSelect, isUserInteracting]);
|
|
198
204
|
// Sync options into filtered list when not searching
|
|
199
205
|
(0, react_1.useEffect)(() => {
|
|
@@ -208,6 +214,12 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
208
214
|
setHasSearched(false);
|
|
209
215
|
}
|
|
210
216
|
}, [options, inputValue]);
|
|
217
|
+
// Debug: Log when selectedValues changes
|
|
218
|
+
(0, react_1.useEffect)(() => {
|
|
219
|
+
console.log('=== selectedValues changed ===');
|
|
220
|
+
console.log('New selectedValues:', selectedValues);
|
|
221
|
+
console.log('Stack trace:', new Error().stack);
|
|
222
|
+
}, [selectedValues]);
|
|
211
223
|
// Close on outside click
|
|
212
224
|
(0, react_1.useEffect)(() => {
|
|
213
225
|
const handler = (e) => {
|
|
@@ -252,9 +264,14 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
252
264
|
}
|
|
253
265
|
}, [onChange, fetchOptions, options, deriveLabel]);
|
|
254
266
|
const handleKeyDown = (0, react_1.useCallback)((e) => {
|
|
267
|
+
console.log('=== handleKeyDown called ===');
|
|
268
|
+
console.log('key:', e.key);
|
|
269
|
+
console.log('isDisabled:', isDisabled);
|
|
270
|
+
console.log('current selectedValues:', selectedValues);
|
|
255
271
|
if (isDisabled)
|
|
256
272
|
return;
|
|
257
273
|
// Set user interaction flag for all keyboard events
|
|
274
|
+
console.log('Setting isUserInteracting to true');
|
|
258
275
|
setIsUserInteracting(true);
|
|
259
276
|
switch (e.key) {
|
|
260
277
|
case 'Enter':
|
|
@@ -299,6 +316,7 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
299
316
|
}
|
|
300
317
|
// Reset the flag after a delay
|
|
301
318
|
setTimeout(() => {
|
|
319
|
+
console.log('Resetting isUserInteracting to false');
|
|
302
320
|
setIsUserInteracting(false);
|
|
303
321
|
}, 1000);
|
|
304
322
|
}, [
|
|
@@ -309,6 +327,7 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
309
327
|
deriveLabel,
|
|
310
328
|
handleKeyboardNavigation,
|
|
311
329
|
isCreatable,
|
|
330
|
+
selectedValues,
|
|
312
331
|
]);
|
|
313
332
|
const emitSelection = (0, react_1.useCallback)((next) => {
|
|
314
333
|
// Backward-compatible callback
|
|
@@ -343,7 +362,12 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
343
362
|
}
|
|
344
363
|
}, [inputValue, isCreatable, onCreateOption]);
|
|
345
364
|
const toggleDropdown = (0, react_1.useCallback)(() => {
|
|
365
|
+
console.log('=== toggleDropdown called ===');
|
|
366
|
+
console.log('isDisabled:', isDisabled);
|
|
367
|
+
console.log('current isOpen:', isOpen);
|
|
368
|
+
console.log('current selectedValues:', selectedValues);
|
|
346
369
|
if (!isDisabled) {
|
|
370
|
+
console.log('Setting isUserInteracting to true');
|
|
347
371
|
setIsUserInteracting(true);
|
|
348
372
|
setIsOpen((prev) => !prev);
|
|
349
373
|
if (!isOpen && inputRef.current) {
|
|
@@ -351,10 +375,11 @@ exports.default = react_1.default.memo(function CreatableSelect({ options = [],
|
|
|
351
375
|
}
|
|
352
376
|
// Reset the flag after a delay
|
|
353
377
|
setTimeout(() => {
|
|
378
|
+
console.log('Resetting isUserInteracting to false');
|
|
354
379
|
setIsUserInteracting(false);
|
|
355
380
|
}, 1000);
|
|
356
381
|
}
|
|
357
|
-
}, [isDisabled, isOpen]);
|
|
382
|
+
}, [isDisabled, isOpen, selectedValues]);
|
|
358
383
|
const clearValue = (0, react_1.useCallback)((e, option) => {
|
|
359
384
|
e.stopPropagation();
|
|
360
385
|
const next = selectedValues.filter((val) => deriveValue(val) !== deriveValue(option));
|