slim-select 3.1.3 → 3.1.4

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.
@@ -151,10 +151,11 @@ export default class SlimSelect {
151
151
  // and onOptionsChange wouldn't be called directly
152
152
  this.setData(data || [])
153
153
  }
154
- // Set up label click handler to open SlimSelect
154
+ // Set up label click handler to toggle SlimSelect
155
+ // This allows clicking the label to open/close, matching the main div behavior
155
156
  this.select.onLabelClick = () => {
156
157
  if (!this.settings.disabled) {
157
- this.open()
158
+ this.settings.isOpen ? this.close() : this.open()
158
159
  }
159
160
  }
160
161
 
@@ -556,17 +556,22 @@ export default class Select {
556
556
 
557
557
  // Add click handler to label
558
558
  const labelClickHandler = (e: MouseEvent) => {
559
+ const target = e.target as HTMLElement
560
+
561
+ // Only continue if the target is the label
562
+ if (target !== label) {
563
+ return
564
+ }
565
+
566
+ // At this point, we know the click is directly on the label element
559
567
  // Prevent default label behavior (focusing the select)
568
+ // Don't stop propagation to allow other handlers (like closing other SlimSelect instances)
560
569
  e.preventDefault()
561
- e.stopPropagation()
570
+ // e.stopPropagation() // dont stop propagation
562
571
 
563
- // Trigger the callback to open SlimSelect
572
+ // Trigger the callback to toggle SlimSelect
564
573
  if (this.onLabelClick) {
565
- // Use setTimeout to ensure this happens after any browser-initiated events
566
- // are prevented by our prevent handlers
567
- setTimeout(() => {
568
- this.onLabelClick!()
569
- }, 0)
574
+ this.onLabelClick!()
570
575
  }
571
576
  }
572
577