@smilodon/core 1.4.0 → 1.4.1

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/index.umd.js CHANGED
@@ -1832,6 +1832,7 @@
1832
1832
  this._pendingFirstRenderMark = false;
1833
1833
  this._pendingSearchRenderMark = false;
1834
1834
  this._rangeAnchorIndex = null;
1835
+ this._customOptionBoundElements = new WeakSet();
1835
1836
  this._shadow = this.attachShadow({ mode: 'open' });
1836
1837
  this._uniqueId = `enhanced-select-${Math.random().toString(36).substr(2, 9)}`;
1837
1838
  this._rendererHelpers = this._buildRendererHelpers();
@@ -3698,24 +3699,37 @@
3698
3699
  if (!optionEl.hasAttribute('tabindex')) {
3699
3700
  optionEl.tabIndex = -1;
3700
3701
  }
3701
- if (!meta.disabled) {
3702
+ if (!this._customOptionBoundElements.has(optionEl)) {
3702
3703
  optionEl.addEventListener('click', (e) => {
3703
- e.stopPropagation(); // Prevent duplicate handling by delegation
3704
+ e.stopPropagation();
3705
+ const current = e.currentTarget;
3706
+ if (current.getAttribute('aria-disabled') === 'true')
3707
+ return;
3708
+ const parsedIndex = Number(current.dataset.index);
3709
+ if (!Number.isFinite(parsedIndex))
3710
+ return;
3704
3711
  const mouseEvent = e;
3705
- this._selectOption(meta.index, {
3712
+ this._selectOption(parsedIndex, {
3706
3713
  shiftKey: mouseEvent.shiftKey,
3707
3714
  toggleKey: mouseEvent.ctrlKey || mouseEvent.metaKey,
3708
3715
  });
3709
3716
  });
3710
3717
  optionEl.addEventListener('keydown', (e) => {
3711
- if (e.key === 'Enter' || e.key === ' ') {
3712
- e.preventDefault();
3713
- this._selectOption(meta.index, {
3714
- shiftKey: e.shiftKey,
3715
- toggleKey: e.ctrlKey || e.metaKey,
3716
- });
3717
- }
3718
+ if (e.key !== 'Enter' && e.key !== ' ')
3719
+ return;
3720
+ const current = e.currentTarget;
3721
+ if (current.getAttribute('aria-disabled') === 'true')
3722
+ return;
3723
+ const parsedIndex = Number(current.dataset.index);
3724
+ if (!Number.isFinite(parsedIndex))
3725
+ return;
3726
+ e.preventDefault();
3727
+ this._selectOption(parsedIndex, {
3728
+ shiftKey: e.shiftKey,
3729
+ toggleKey: e.ctrlKey || e.metaKey,
3730
+ });
3718
3731
  });
3732
+ this._customOptionBoundElements.add(optionEl);
3719
3733
  }
3720
3734
  return optionEl;
3721
3735
  }