Skip to content

Commit

Permalink
Don't select the item if it's an href (#3057)
Browse files Browse the repository at this point in the history
Co-authored-by: owenniblock <[email protected]>
  • Loading branch information
owenniblock and owenniblock authored Sep 5, 2024
1 parent 269b02f commit 96b42db
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/three-points-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/view-components': patch
---

Don't select SelectPanel::Item when item is a link
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/components/primer/alpha/select_panel_element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,9 @@ export class SelectPanelElement extends HTMLElement {
const itemContent = this.#getItemContent(item)

if (this.selectVariant === 'single') {
// Don't check anything if we have an href
if (itemContent?.getAttribute('href')) return

// disallow unchecking checked item in single-select mode
if (!currentlyChecked) {
for (const el of this.items) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
)) do |panel| %>
<% panel.with_show_button { "Panel" } %>
<% panel.with_item(label: "GitHub", href: "https://github.com") %>
<% panel.with_item(label: "Microsoft", href: "https://microsoft.com") %>
<% panel.with_item(label: "Microsoft", href: "https://microsoft.com", active: true) %>
<% panel.with_item(label: "Primer", href: "https://primer.style") %>
<% panel.with_item(label: "Catalyst", href: "https://catalyst.rocks") %>
<% end %>
Expand Down

0 comments on commit 96b42db

Please sign in to comment.