svelte-select-5 6.1.1 → 6.1.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/Select.svelte CHANGED
@@ -760,12 +760,17 @@
760
760
  });
761
761
 
762
762
  // Handle external changes to justValue (allows setting value via justValue)
763
+ // Also handles case where justValue is set before items are loaded
763
764
  $effect(() => {
764
765
  const computed = computeJustValue();
765
766
  const isExternalChange = justValue !== prevJustValue &&
766
767
  JSON.stringify(justValue) !== JSON.stringify(computed);
767
768
 
768
- if (isExternalChange && items) {
769
+ // Update value if: external justValue change, OR items loaded while justValue is set but value is empty
770
+ const needsValueUpdate = isExternalChange ||
771
+ (items && justValue != null && !value && JSON.stringify(justValue) !== JSON.stringify(computed));
772
+
773
+ if (needsValueUpdate && items) {
769
774
  if (multiple) {
770
775
  value = justValue
771
776
  ? items.filter(item => justValue.includes(item[itemId]))
@@ -782,6 +787,9 @@
782
787
  // Read-only props - always reflect current state, external changes are ignored
783
788
  $effect(() => {
784
789
  readonlyValue = value;
790
+ });
791
+
792
+ $effect(() => {
785
793
  readonlyId = computeJustValue();
786
794
  });
787
795
 
@@ -834,6 +842,8 @@
834
842
  });
835
843
 
836
844
  onDestroy(() => {
845
+ clearTimeout(timeout);
846
+ clearTimeout(isScrollingTimer);
837
847
  list?.remove();
838
848
  });
839
849
  </script>
@@ -760,12 +760,17 @@
760
760
  });
761
761
 
762
762
  // Handle external changes to justValue (allows setting value via justValue)
763
+ // Also handles case where justValue is set before items are loaded
763
764
  $effect(() => {
764
765
  const computed = computeJustValue();
765
766
  const isExternalChange = justValue !== prevJustValue &&
766
767
  JSON.stringify(justValue) !== JSON.stringify(computed);
767
768
 
768
- if (isExternalChange && items) {
769
+ // Update value if: external justValue change, OR items loaded while justValue is set but value is empty
770
+ const needsValueUpdate = isExternalChange ||
771
+ (items && justValue != null && !value && JSON.stringify(justValue) !== JSON.stringify(computed));
772
+
773
+ if (needsValueUpdate && items) {
769
774
  if (multiple) {
770
775
  value = justValue
771
776
  ? items.filter(item => justValue.includes(item[itemId]))
@@ -782,6 +787,9 @@
782
787
  // Read-only props - always reflect current state, external changes are ignored
783
788
  $effect(() => {
784
789
  readonlyValue = value;
790
+ });
791
+
792
+ $effect(() => {
785
793
  readonlyId = computeJustValue();
786
794
  });
787
795
 
@@ -834,6 +842,8 @@
834
842
  });
835
843
 
836
844
  onDestroy(() => {
845
+ clearTimeout(timeout);
846
+ clearTimeout(isScrollingTimer);
837
847
  list?.remove();
838
848
  });
839
849
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-select-5",
3
- "version": "6.1.1",
3
+ "version": "6.1.2",
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)",