@primer/view-components 0.31.1-rc.0b9baf9f → 0.31.1-rc.681ebd27

Sign up to get free protection for your applications and to get access to all the features.
@@ -692,10 +692,10 @@ _SelectPanelElement_updateItemVisibility = function _SelectPanelElement_updateIt
692
692
  }
693
693
  }
694
694
  else if (value && !__classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").has(value) && this.isItemChecked(item)) {
695
- __classPrivateFieldSet(this, _SelectPanelElement_hasLoadedData, true, "f");
696
695
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
697
696
  }
698
697
  }
698
+ __classPrivateFieldSet(this, _SelectPanelElement_hasLoadedData, true, "f");
699
699
  if (!this.noResults)
700
700
  return;
701
701
  if (__classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_inErrorState).call(this)) {
@@ -824,7 +824,8 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
824
824
  // interfere with events fired by menu items whose behavior is specified outside the library.
825
825
  if (this.selectVariant !== 'multiple' && this.selectVariant !== 'single')
826
826
  return;
827
- const checked = !this.isItemChecked(item);
827
+ const currentlyChecked = this.isItemChecked(item);
828
+ const checked = !currentlyChecked;
828
829
  const activationSuccess = this.dispatchEvent(new CustomEvent('beforeItemActivated', {
829
830
  bubbles: true,
830
831
  detail: { item, checked },
@@ -834,18 +835,18 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
834
835
  return;
835
836
  const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
836
837
  if (this.selectVariant === 'single') {
837
- const value = this.selectedItems[0]?.value;
838
- const element = this.visibleItems.find(el => __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, el)?.getAttribute('data-value') === value);
839
- if (element) {
840
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, element)?.setAttribute(this.ariaSelectionType, 'false');
841
- }
842
- __classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").clear();
843
- // Only check, never uncheck here. Single-select mode does not allow unchecking a checked item.
844
- if (checked) {
845
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
846
- itemContent?.setAttribute(this.ariaSelectionType, 'true');
838
+ // disallow unchecking checked item in single-select mode
839
+ if (!currentlyChecked) {
840
+ for (const el of this.items) {
841
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, el)?.setAttribute(this.ariaSelectionType, 'false');
842
+ }
843
+ __classPrivateFieldGet(this, _SelectPanelElement_selectedItems, "f").clear();
844
+ if (checked) {
845
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_addSelectedItem).call(this, item);
846
+ itemContent?.setAttribute(this.ariaSelectionType, 'true');
847
+ }
848
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_setDynamicLabel).call(this);
847
849
  }
848
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_setDynamicLabel).call(this);
849
850
  }
850
851
  else {
851
852
  // multi-select mode allows unchecking a checked item
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.31.1-rc.0b9baf9f",
3
+ "version": "0.31.1-rc.681ebd27",
4
4
  "description": "ViewComponents for the Primer Design System",
5
5
  "main": "app/assets/javascripts/primer_view_components.js",
6
6
  "module": "app/components/primer/primer.js",
@@ -92,7 +92,9 @@
92
92
  "stylelint": "^16.1.0",
93
93
  "stylelint-config-standard": "^36.0.0",
94
94
  "tslib": "^2.4.0",
95
- "typescript": "^5.2.2"
95
+ "typescript": "^5.2.2",
96
+ "vite": "^5.3.5",
97
+ "vite-plugin-ruby": "^5.0.0"
96
98
  },
97
99
  "prettier": "@github/prettier-config",
98
100
  "browserslist": "extends @github/browserslist-config"