svelte-select-5 6.1.4 → 6.1.6
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/Select.svelte +17 -7
- package/no-styles/Select.svelte +17 -7
- package/package.json +1 -1
package/Select.svelte
CHANGED
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
let _inputAttributes = $state({});
|
|
164
164
|
let prevJustValue = $state(undefined);
|
|
165
165
|
let isScrollingTimer;
|
|
166
|
+
let autoUpdateInitialized = false;
|
|
166
167
|
|
|
167
168
|
// Floating UI config - using closure for listOffset to capture current value
|
|
168
169
|
let _floatingConfig = {
|
|
@@ -385,13 +386,18 @@
|
|
|
385
386
|
if (!value || (multiple ? value.some((selection) => !selection || !selection[itemId]) : !value[itemId])) return;
|
|
386
387
|
|
|
387
388
|
if (Array.isArray(value)) {
|
|
388
|
-
//
|
|
389
|
+
// Check if any value needs updating - compare properties, not references
|
|
390
|
+
// (Svelte 5 proxies have different identities than their targets)
|
|
389
391
|
let needsUpdate = false;
|
|
390
392
|
const newValue = value.map((selection) => {
|
|
391
393
|
const found = findItem(selection);
|
|
392
|
-
if
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
// Only update if found item has different properties (not just different reference)
|
|
395
|
+
if (found && found[itemId] === selection[itemId]) {
|
|
396
|
+
// Same itemId - check if other properties differ using JSON comparison
|
|
397
|
+
if (JSON.stringify(found) !== JSON.stringify(selection)) {
|
|
398
|
+
needsUpdate = true;
|
|
399
|
+
return found;
|
|
400
|
+
}
|
|
395
401
|
}
|
|
396
402
|
return selection;
|
|
397
403
|
});
|
|
@@ -400,8 +406,11 @@
|
|
|
400
406
|
}
|
|
401
407
|
} else {
|
|
402
408
|
const found = findItem();
|
|
403
|
-
if
|
|
404
|
-
|
|
409
|
+
// Only update if found item has different properties
|
|
410
|
+
if (found && found[itemId] === value[itemId]) {
|
|
411
|
+
if (JSON.stringify(found) !== JSON.stringify(value)) {
|
|
412
|
+
value = found;
|
|
413
|
+
}
|
|
405
414
|
}
|
|
406
415
|
}
|
|
407
416
|
}
|
|
@@ -845,7 +854,8 @@
|
|
|
845
854
|
});
|
|
846
855
|
|
|
847
856
|
$effect(() => {
|
|
848
|
-
if (container && floatingConfig?.autoUpdate === undefined) {
|
|
857
|
+
if (container && !autoUpdateInitialized && floatingConfig?.autoUpdate === undefined) {
|
|
858
|
+
autoUpdateInitialized = true;
|
|
849
859
|
_floatingConfig.autoUpdate = true;
|
|
850
860
|
}
|
|
851
861
|
});
|
package/no-styles/Select.svelte
CHANGED
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
let _inputAttributes = $state({});
|
|
164
164
|
let prevJustValue = $state(undefined);
|
|
165
165
|
let isScrollingTimer;
|
|
166
|
+
let autoUpdateInitialized = false;
|
|
166
167
|
|
|
167
168
|
// Floating UI config - using closure for listOffset to capture current value
|
|
168
169
|
let _floatingConfig = {
|
|
@@ -385,13 +386,18 @@
|
|
|
385
386
|
if (!value || (multiple ? value.some((selection) => !selection || !selection[itemId]) : !value[itemId])) return;
|
|
386
387
|
|
|
387
388
|
if (Array.isArray(value)) {
|
|
388
|
-
//
|
|
389
|
+
// Check if any value needs updating - compare properties, not references
|
|
390
|
+
// (Svelte 5 proxies have different identities than their targets)
|
|
389
391
|
let needsUpdate = false;
|
|
390
392
|
const newValue = value.map((selection) => {
|
|
391
393
|
const found = findItem(selection);
|
|
392
|
-
if
|
|
393
|
-
|
|
394
|
-
|
|
394
|
+
// Only update if found item has different properties (not just different reference)
|
|
395
|
+
if (found && found[itemId] === selection[itemId]) {
|
|
396
|
+
// Same itemId - check if other properties differ using JSON comparison
|
|
397
|
+
if (JSON.stringify(found) !== JSON.stringify(selection)) {
|
|
398
|
+
needsUpdate = true;
|
|
399
|
+
return found;
|
|
400
|
+
}
|
|
395
401
|
}
|
|
396
402
|
return selection;
|
|
397
403
|
});
|
|
@@ -400,8 +406,11 @@
|
|
|
400
406
|
}
|
|
401
407
|
} else {
|
|
402
408
|
const found = findItem();
|
|
403
|
-
if
|
|
404
|
-
|
|
409
|
+
// Only update if found item has different properties
|
|
410
|
+
if (found && found[itemId] === value[itemId]) {
|
|
411
|
+
if (JSON.stringify(found) !== JSON.stringify(value)) {
|
|
412
|
+
value = found;
|
|
413
|
+
}
|
|
405
414
|
}
|
|
406
415
|
}
|
|
407
416
|
}
|
|
@@ -845,7 +854,8 @@
|
|
|
845
854
|
});
|
|
846
855
|
|
|
847
856
|
$effect(() => {
|
|
848
|
-
if (container && floatingConfig?.autoUpdate === undefined) {
|
|
857
|
+
if (container && !autoUpdateInitialized && floatingConfig?.autoUpdate === undefined) {
|
|
858
|
+
autoUpdateInitialized = true;
|
|
849
859
|
_floatingConfig.autoUpdate = true;
|
|
850
860
|
}
|
|
851
861
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-select-5",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.6",
|
|
4
4
|
"description": "A <Select> component for Svelte 5 apps (fork of svelte-select)",
|
|
5
5
|
"repository": "https://github.com/Dbone29/svelte-select-5.git",
|
|
6
6
|
"author": "Robert Balfré <rob.balfre@gmail.com> (https://github.com/rob-balfre)",
|