Skip to content

Commit 96b42db

Browse files
authoredSep 5, 2024··
Don't select the item if it's an href (#3057)
Co-authored-by: owenniblock <owenniblock@users.noreply.github.com>
1 parent 269b02f commit 96b42db

File tree

10 files changed

+9
-1
lines changed

10 files changed

+9
-1
lines changed
 

‎.changeset/three-points-cross.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/view-components': patch
3+
---
4+
5+
Don't select SelectPanel::Item when item is a link

‎app/components/primer/alpha/select_panel_element.ts

+3
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,9 @@ export class SelectPanelElement extends HTMLElement {
882882
const itemContent = this.#getItemContent(item)
883883

884884
if (this.selectVariant === 'single') {
885+
// Don't check anything if we have an href
886+
if (itemContent?.getAttribute('href')) return
887+
885888
// disallow unchecking checked item in single-select mode
886889
if (!currentlyChecked) {
887890
for (const el of this.items) {

‎previews/primer/alpha/select_panel_preview/list_of_links.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)) do |panel| %>
99
<% panel.with_show_button { "Panel" } %>
1010
<% panel.with_item(label: "GitHub", href: "https://github.com") %>
11-
<% panel.with_item(label: "Microsoft", href: "https://microsoft.com") %>
11+
<% panel.with_item(label: "Microsoft", href: "https://microsoft.com", active: true) %>
1212
<% panel.with_item(label: "Primer", href: "https://primer.style") %>
1313
<% panel.with_item(label: "Catalyst", href: "https://catalyst.rocks") %>
1414
<% end %>

0 commit comments

Comments
 (0)
Please sign in to comment.