Skip to content

Commit bc69331

Browse files
HDingerCopilot
andauthored
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 0f57fd3 commit bc69331

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

app/components/primer/alpha/action_menu/action_menu_element.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,19 @@ export class ActionMenuElement extends HTMLElement {
505505
this.#originalLabel ||= invokerLabel.textContent || ''
506506
let itemLabel: string | undefined
507507
if (this.selectVariant === 'single') {
508-
itemLabel = this.querySelector('[aria-checked=true] .ActionListItem-label')?.textContent
508+
itemLabel = this.querySelector('[aria-checked=true] .ActionListItem-label')?.textContent?.trim()
509509
} else if (this.selectVariant === 'multiple') {
510510
itemLabel = Array.from(this.querySelectorAll(`[aria-checked=true] .ActionListItem-label`))
511-
.map(label => label.textContent.trim())
511+
.map(label => (label.textContent || '').trim())
512+
.filter(Boolean)
512513
.join(', ')
513514
}
514515
itemLabel ||= this.#originalLabel
515516
if (itemLabel && this.dynamicLabel) {
516517
const prefixSpan = document.createElement('span')
517518
prefixSpan.classList.add('color-fg-muted')
518519
const contentSpan = document.createElement('span')
519-
prefixSpan.textContent = `${this.dynamicLabelPrefix} `
520+
prefixSpan.textContent = this.dynamicLabelPrefix ? `${this.dynamicLabelPrefix} ` : ''
520521
contentSpan.textContent = itemLabel
521522
invokerLabel.replaceChildren(prefixSpan, contentSpan)
522523
} else {

0 commit comments

Comments
 (0)