@primer/view-components 0.31.0-rc.b5696d3b → 0.31.0-rc.dab49dc3

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.
@@ -6,7 +6,6 @@ type SelectedItem = {
6
6
  label: string | null | undefined;
7
7
  value: string | null | undefined;
8
8
  inputName: string | null | undefined;
9
- element: SelectPanelItem;
10
9
  };
11
10
  export type SelectPanelItem = HTMLLIElement;
12
11
  export type FilterFn = (item: SelectPanelItem, query: string) => boolean;
@@ -55,6 +55,7 @@ const updateWhenVisible = (() => {
55
55
  }));
56
56
  resizeObserver.observe(el.ownerDocument.documentElement);
57
57
  el.addEventListener('dialog:close', () => {
58
+ el.invokerElement?.setAttribute('aria-expanded', 'false');
58
59
  anchors.delete(el);
59
60
  });
60
61
  el.addEventListener('dialog:open', () => {
@@ -252,6 +253,7 @@ let SelectPanelElement = class SelectPanelElement extends HTMLElement {
252
253
  if (event.target === this.dialog && event.type === 'close') {
253
254
  // Remove data-ready so it can be set the next time the panel is opened
254
255
  this.dialog.removeAttribute('data-ready');
256
+ this.invokerElement?.setAttribute('aria-expanded', 'false');
255
257
  this.dispatchEvent(new CustomEvent('panelClosed', {
256
258
  detail: { panel: this },
257
259
  bubbles: true,
@@ -301,6 +303,7 @@ let SelectPanelElement = class SelectPanelElement extends HTMLElement {
301
303
  show() {
302
304
  this.updateAnchorPosition();
303
305
  this.dialog.showModal();
306
+ this.invokerElement?.setAttribute('aria-expanded', 'true');
304
307
  const event = new CustomEvent('dialog:open', {
305
308
  detail: { dialog: this.dialog },
306
309
  });
@@ -499,7 +502,6 @@ _SelectPanelElement_addSelectedItem = function _SelectPanelElement_addSelectedIt
499
502
  value,
500
503
  label: itemContent.querySelector('.ActionListItem-label')?.textContent?.trim(),
501
504
  inputName: itemContent.getAttribute('data-input-name'),
502
- element: item,
503
505
  });
504
506
  }
505
507
  };
@@ -609,7 +611,9 @@ _SelectPanelElement_handleSearchFieldEvent = function _SelectPanelElement_handle
609
611
  if (key === 'Enter') {
610
612
  const item = this.visibleItems[0];
611
613
  if (item) {
612
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_handleItemActivated).call(this, item, false);
614
+ const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
615
+ if (itemContent)
616
+ itemContent.click();
613
617
  }
614
618
  }
615
619
  else if (key === 'ArrowDown') {
@@ -622,14 +626,18 @@ _SelectPanelElement_handleSearchFieldEvent = function _SelectPanelElement_handle
622
626
  else if (key === 'Home') {
623
627
  const item = this.visibleItems[0];
624
628
  if (item) {
625
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item).focus();
629
+ const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
630
+ if (itemContent)
631
+ itemContent.focus();
626
632
  event.preventDefault();
627
633
  }
628
634
  }
629
635
  else if (key === 'End') {
630
636
  if (this.visibleItems.length > 0) {
631
637
  const item = this.visibleItems[this.visibleItems.length - 1];
632
- __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item).focus();
638
+ const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
639
+ if (itemContent)
640
+ itemContent.focus();
633
641
  event.preventDefault();
634
642
  }
635
643
  }
@@ -797,7 +805,7 @@ _SelectPanelElement_handleDialogItemActivated = function _SelectPanelElement_han
797
805
  dialog.addEventListener('close', handleDialogClose, { signal });
798
806
  dialog.addEventListener('cancel', handleDialogClose, { signal });
799
807
  };
800
- _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleItemActivated(item, shouldClose = true) {
808
+ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleItemActivated(item) {
801
809
  // Hide popover after current event loop to prevent changes in focus from
802
810
  // altering the target of the event. Not doing this specifically affects
803
811
  // <a> tags. It causes the event to be sent to the currently focused element
@@ -806,7 +814,7 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
806
814
  // works fine.
807
815
  if (this.selectVariant !== 'multiple') {
808
816
  setTimeout(() => {
809
- if (this.open && shouldClose) {
817
+ if (this.open) {
810
818
  this.hide();
811
819
  }
812
820
  });
@@ -825,7 +833,8 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
825
833
  return;
826
834
  const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
827
835
  if (this.selectVariant === 'single') {
828
- const element = this.selectedItems[0]?.element;
836
+ const value = this.selectedItems[0]?.value;
837
+ const element = this.visibleItems.find(el => __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, el)?.getAttribute('data-value') === value);
829
838
  if (element) {
830
839
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, element)?.setAttribute(this.ariaSelectionType, 'false');
831
840
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.31.0-rc.b5696d3b",
3
+ "version": "0.31.0-rc.dab49dc3",
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",
@@ -991,6 +991,12 @@
991
991
  "name": "description",
992
992
  "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
993
993
  "parameters": [
994
+ {
995
+ "name": "legacy_content",
996
+ "type": "String",
997
+ "default": "N/A",
998
+ "description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
999
+ },
994
1000
  {
995
1001
  "name": "test_selector",
996
1002
  "type": "String",
@@ -5554,6 +5560,12 @@
5554
5560
  "name": "description",
5555
5561
  "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
5556
5562
  "parameters": [
5563
+ {
5564
+ "name": "legacy_content",
5565
+ "type": "String",
5566
+ "default": "N/A",
5567
+ "description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
5568
+ },
5557
5569
  {
5558
5570
  "name": "test_selector",
5559
5571
  "type": "String",
@@ -8093,6 +8105,19 @@
8093
8105
  "color-contrast"
8094
8106
  ]
8095
8107
  }
8108
+ },
8109
+ {
8110
+ "preview_path": "primer/alpha/select_panel/list_of_links",
8111
+ "name": "list_of_links",
8112
+ "snapshot": "interactive",
8113
+ "skip_rules": {
8114
+ "wont_fix": [
8115
+ "region"
8116
+ ],
8117
+ "will_fix": [
8118
+ "color-contrast"
8119
+ ]
8120
+ }
8096
8121
  }
8097
8122
  ],
8098
8123
  "subcomponents": [
@@ -14699,6 +14724,12 @@
14699
14724
  "name": "description",
14700
14725
  "description": "Description content that complements the item's label, with optional test_selector.\nSee `ActionList`'s `description_scheme` argument for layout options.",
14701
14726
  "parameters": [
14727
+ {
14728
+ "name": "legacy_content",
14729
+ "type": "String",
14730
+ "default": "N/A",
14731
+ "description": "Slot content, provided for backwards-compatibility. Pass a content block instead, or call `with_content`, eg. `component.with_description { \"My description\" }` or `component.with_description.with_content(\"My description\")`."
14732
+ },
14702
14733
  {
14703
14734
  "name": "test_selector",
14704
14735
  "type": "String",
@@ -6160,6 +6160,19 @@
6160
6160
  "color-contrast"
6161
6161
  ]
6162
6162
  }
6163
+ },
6164
+ {
6165
+ "preview_path": "primer/alpha/select_panel/list_of_links",
6166
+ "name": "list_of_links",
6167
+ "snapshot": "interactive",
6168
+ "skip_rules": {
6169
+ "wont_fix": [
6170
+ "region"
6171
+ ],
6172
+ "will_fix": [
6173
+ "color-contrast"
6174
+ ]
6175
+ }
6163
6176
  }
6164
6177
  ]
6165
6178
  },