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

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ type SelectedItem = {
6
6
  label: string | null | undefined;
7
7
  value: string | null | undefined;
8
8
  inputName: string | null | undefined;
9
+ element: SelectPanelItem;
9
10
  };
10
11
  export type SelectPanelItem = HTMLLIElement;
11
12
  export type FilterFn = (item: SelectPanelItem, query: string) => boolean;
@@ -502,6 +502,7 @@ _SelectPanelElement_addSelectedItem = function _SelectPanelElement_addSelectedIt
502
502
  value,
503
503
  label: itemContent.querySelector('.ActionListItem-label')?.textContent?.trim(),
504
504
  inputName: itemContent.getAttribute('data-input-name'),
505
+ element: item,
505
506
  });
506
507
  }
507
508
  };
@@ -611,9 +612,7 @@ _SelectPanelElement_handleSearchFieldEvent = function _SelectPanelElement_handle
611
612
  if (key === 'Enter') {
612
613
  const item = this.visibleItems[0];
613
614
  if (item) {
614
- const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
615
- if (itemContent)
616
- itemContent.click();
615
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_handleItemActivated).call(this, item, false);
617
616
  }
618
617
  }
619
618
  else if (key === 'ArrowDown') {
@@ -626,18 +625,14 @@ _SelectPanelElement_handleSearchFieldEvent = function _SelectPanelElement_handle
626
625
  else if (key === 'Home') {
627
626
  const item = this.visibleItems[0];
628
627
  if (item) {
629
- const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
630
- if (itemContent)
631
- itemContent.focus();
628
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item).focus();
632
629
  event.preventDefault();
633
630
  }
634
631
  }
635
632
  else if (key === 'End') {
636
633
  if (this.visibleItems.length > 0) {
637
634
  const item = this.visibleItems[this.visibleItems.length - 1];
638
- const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
639
- if (itemContent)
640
- itemContent.focus();
635
+ __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item).focus();
641
636
  event.preventDefault();
642
637
  }
643
638
  }
@@ -805,7 +800,7 @@ _SelectPanelElement_handleDialogItemActivated = function _SelectPanelElement_han
805
800
  dialog.addEventListener('close', handleDialogClose, { signal });
806
801
  dialog.addEventListener('cancel', handleDialogClose, { signal });
807
802
  };
808
- _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleItemActivated(item) {
803
+ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleItemActivated(item, shouldClose = true) {
809
804
  // Hide popover after current event loop to prevent changes in focus from
810
805
  // altering the target of the event. Not doing this specifically affects
811
806
  // <a> tags. It causes the event to be sent to the currently focused element
@@ -814,7 +809,7 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
814
809
  // works fine.
815
810
  if (this.selectVariant !== 'multiple') {
816
811
  setTimeout(() => {
817
- if (this.open) {
812
+ if (this.open && shouldClose) {
818
813
  this.hide();
819
814
  }
820
815
  });
@@ -833,8 +828,7 @@ _SelectPanelElement_handleItemActivated = function _SelectPanelElement_handleIte
833
828
  return;
834
829
  const itemContent = __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, item);
835
830
  if (this.selectVariant === 'single') {
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);
831
+ const element = this.selectedItems[0]?.element;
838
832
  if (element) {
839
833
  __classPrivateFieldGet(this, _SelectPanelElement_instances, "m", _SelectPanelElement_getItemContent).call(this, element)?.setAttribute(this.ariaSelectionType, 'false');
840
834
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer/view-components",
3
- "version": "0.31.0-rc.dab49dc3",
3
+ "version": "0.31.0-rc.dae1961b",
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",
@@ -8105,19 +8105,6 @@
8105
8105
  "color-contrast"
8106
8106
  ]
8107
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
- }
8121
8108
  }
8122
8109
  ],
8123
8110
  "subcomponents": [
@@ -6160,19 +6160,6 @@
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
- }
6176
6163
  }
6177
6164
  ]
6178
6165
  },