svelte-select-5 6.1.3 → 6.1.5

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 CHANGED
@@ -286,12 +286,8 @@
286
286
  }
287
287
 
288
288
  function setupMulti() {
289
- if (value) {
290
- if (Array.isArray(value)) {
291
- value = [...value];
292
- } else {
293
- value = [value];
294
- }
289
+ if (value && !Array.isArray(value)) {
290
+ value = [value];
295
291
  }
296
292
  }
297
293
 
@@ -389,9 +385,32 @@
389
385
  if (!value || (multiple ? value.some((selection) => !selection || !selection[itemId]) : !value[itemId])) return;
390
386
 
391
387
  if (Array.isArray(value)) {
392
- value = value.map((selection) => findItem(selection) || selection);
388
+ // Check if any value needs updating - compare properties, not references
389
+ // (Svelte 5 proxies have different identities than their targets)
390
+ let needsUpdate = false;
391
+ const newValue = value.map((selection) => {
392
+ const found = findItem(selection);
393
+ // Only update if found item has different properties (not just different reference)
394
+ if (found && found[itemId] === selection[itemId]) {
395
+ // Same itemId - check if other properties differ using JSON comparison
396
+ if (JSON.stringify(found) !== JSON.stringify(selection)) {
397
+ needsUpdate = true;
398
+ return found;
399
+ }
400
+ }
401
+ return selection;
402
+ });
403
+ if (needsUpdate) {
404
+ value = newValue;
405
+ }
393
406
  } else {
394
- value = findItem() || value;
407
+ const found = findItem();
408
+ // Only update if found item has different properties
409
+ if (found && found[itemId] === value[itemId]) {
410
+ if (JSON.stringify(found) !== JSON.stringify(value)) {
411
+ value = found;
412
+ }
413
+ }
395
414
  }
396
415
  }
397
416
 
@@ -286,12 +286,8 @@
286
286
  }
287
287
 
288
288
  function setupMulti() {
289
- if (value) {
290
- if (Array.isArray(value)) {
291
- value = [...value];
292
- } else {
293
- value = [value];
294
- }
289
+ if (value && !Array.isArray(value)) {
290
+ value = [value];
295
291
  }
296
292
  }
297
293
 
@@ -389,9 +385,32 @@
389
385
  if (!value || (multiple ? value.some((selection) => !selection || !selection[itemId]) : !value[itemId])) return;
390
386
 
391
387
  if (Array.isArray(value)) {
392
- value = value.map((selection) => findItem(selection) || selection);
388
+ // Check if any value needs updating - compare properties, not references
389
+ // (Svelte 5 proxies have different identities than their targets)
390
+ let needsUpdate = false;
391
+ const newValue = value.map((selection) => {
392
+ const found = findItem(selection);
393
+ // Only update if found item has different properties (not just different reference)
394
+ if (found && found[itemId] === selection[itemId]) {
395
+ // Same itemId - check if other properties differ using JSON comparison
396
+ if (JSON.stringify(found) !== JSON.stringify(selection)) {
397
+ needsUpdate = true;
398
+ return found;
399
+ }
400
+ }
401
+ return selection;
402
+ });
403
+ if (needsUpdate) {
404
+ value = newValue;
405
+ }
393
406
  } else {
394
- value = findItem() || value;
407
+ const found = findItem();
408
+ // Only update if found item has different properties
409
+ if (found && found[itemId] === value[itemId]) {
410
+ if (JSON.stringify(found) !== JSON.stringify(value)) {
411
+ value = found;
412
+ }
413
+ }
395
414
  }
396
415
  }
397
416
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-select-5",
3
- "version": "6.1.3",
3
+ "version": "6.1.5",
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)",