Skip to content

Commit

Permalink
fix(searchable-dropdown): add part attribute to list-items
Browse files Browse the repository at this point in the history
Closes #905
  • Loading branch information
asbjornhaland committed Oct 11, 2023
1 parent 43a3e00 commit 31bff96
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .changeset/ten-pumpkins-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@equinor/fusion-wc-searchable-dropdown': patch
---

Add `part` attribute to list items.

This will allow styling the list item outside the `shadowRoot`.

```css
fwc-searchable-dropdown::part(list-item) {
--fwc-list-item-vertical-padding: 4px;
}
```
6 changes: 4 additions & 2 deletions packages/searchable-dropdown/src/dropdown/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class SearchableDropdownElement
/* Sett checkmark on selected items */
if (item.meta === 'check') {
return html`<fwc-check-list-item
part="list-item"
key=${item.id}
class=${classMap(itemClasses)}
disabled=${ifDefined(disabled)}
Expand All @@ -158,6 +159,7 @@ export class SearchableDropdownElement
}

return html`<fwc-list-item
part="list-item"
rootTabbable=${true}
wrapFocus=${true}
key=${item.id}
Expand Down Expand Up @@ -218,10 +220,10 @@ export class SearchableDropdownElement
});
},
pending: () =>
html`<fwc-list-item disabled=${true}><fwc-dots-progress size="small" color="primary" /></fwc-list-item>`,
html`<fwc-list-item part="list-item" disabled=${true}><fwc-dots-progress size="small" color="primary" /></fwc-list-item>`,
/* Error from resolvers searchQuery Promise */
error: (e: unknown) =>
html`<fwc-list-item disabled=${true} class="item-error">
html`<fwc-list-item part="list-item" disabled=${true} class="item-error">
<span class="item-text"><span class="item-title">${e}</span></span>
</fwc-list-item>`,
})}
Expand Down

0 comments on commit 31bff96

Please sign in to comment.