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.
- package/dist/react/index.js +49 -51
- package/dist/react/index.umd.js +1 -1
- package/dist/slimselect.cjs.js +1 -1
- package/dist/slimselect.cjs.js.map +1 -1
- package/dist/slimselect.es.js +2 -4
- package/dist/slimselect.es.js.map +1 -1
- package/dist/slimselect.iife.js +1 -1
- package/dist/slimselect.iife.js.map +1 -1
- package/dist/slimselect.js +1 -1
- package/dist/slimselect.js.map +1 -1
- package/dist/vue/index.js +26 -28
- package/dist/vue/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/slim-select/index.test.ts +167 -0
- package/src/slim-select/index.ts +3 -2
- package/src/slim-select/select.ts +12 -7
package/src/slim-select/index.ts
CHANGED
|
@@ -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
|
|
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
|
|
572
|
+
// Trigger the callback to toggle SlimSelect
|
|
564
573
|
if (this.onLabelClick) {
|
|
565
|
-
|
|
566
|
-
// are prevented by our prevent handlers
|
|
567
|
-
setTimeout(() => {
|
|
568
|
-
this.onLabelClick!()
|
|
569
|
-
}, 0)
|
|
574
|
+
this.onLabelClick!()
|
|
570
575
|
}
|
|
571
576
|
}
|
|
572
577
|
|