Skip to content

Commit 1b8f5ae

Browse files
authored
fix(dropdown): styles for slotted menu (#2713)
1 parent 4df476c commit 1b8f5ae

File tree

2 files changed

+41
-35
lines changed

2 files changed

+41
-35
lines changed

elements/pf-dropdown/pf-dropdown.css

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,50 @@ slot[name="trigger"] {
3636
cursor: pointer;
3737
}
3838

39-
pf-dropdown-menu {
40-
position: absolute;
39+
pf-dropdown-menu,
40+
::slotted(pf-dropdown-menu) {
41+
position: absolute !important;
4142
top: var(
4243
--pf-c-dropdown__menu--Top,
4344
calc(100% + var(--pf-global--spacer--xs, 0.25rem))
44-
);
45-
left: 0;
45+
) !important;
46+
left: 0 !important;
4647
z-index: var(
4748
--pf-c-dropdown__menu--ZIndex,
4849
var(--pf-global--ZIndex--sm, 200)
49-
);
50+
) !important;
5051
padding-top: var(
5152
--pf-c-dropdown__menu--PaddingTop,
5253
var(--pf-global--spacer--sm, 0.5rem)
53-
);
54+
) !important;
5455
padding-bottom: var(
5556
--pf-c-dropdown__menu--PaddingBottom,
5657
var(--pf-global--spacer--sm, 0.5rem)
57-
);
58-
background: var(--pf-c-dropdown__menu--BackgroundColor, #fff);
59-
background-clip: padding-box;
58+
) !important;
59+
background: var(--pf-c-dropdown__menu--BackgroundColor, #fff) !important;
60+
background-clip: padding-box !important;
6061
box-shadow: var(
6162
--pf-c-dropdown__menu--BoxShadow,
6263
var(
6364
--pf-global--BoxShadow--md,
6465
0 0.25rem 0.5rem 0rem rgba(3, 3, 3, 0.12),
6566
0 0 0.25rem 0 rgba(3, 3, 3, 0.06)
6667
)
67-
);
68-
min-width: 100%;
69-
margin: 0;
68+
) !important;
69+
min-width: 100% !important;
70+
margin: 0 !important;
7071
}
7172

7273
:host([disabled]) :is(pf-dropdown-menu, ::slotted(pf-dropdown-menu)) {
7374
pointer-events: none;
7475
cursor: not-allowed;
7576
}
7677

78+
.expanded pf-dropdown-menu,
79+
.expanded ::slotted(pf-dropdown-menu) {
80+
display: block !important;
81+
}
82+
7783
pf-button.disabled::part(button),
7884
:host([disabled]) ::slotted([slot="trigger"]) {
7985
color: var(---pf-c-dropdown__menu-item--disabled--Color, #6a6e73) !important;

elements/pf-dropdown/pf-dropdown.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -99,29 +99,29 @@ export class PfDropdown extends LitElement {
9999
const { anchor, alignment, styles = {} } = this.#float;
100100
const { disabled } = this;
101101
return html`
102-
<div class="${classMap({ expanded, [anchor ?? '']: !!anchor, [alignment ?? '']: !!alignment })}"
103-
style="${styleMap(styles)}"
104-
@slotchange="${this.#onSlotchange}">
105-
<slot name="trigger"
106-
@keydown="${this.#onButtonKeydown}"
107-
@click="${() => this.toggle()}">
108-
<pf-button variant="control"
109-
icon="caret-down"
110-
icon-set="fas">Dropdown</pf-button>
111-
</slot>
112-
<slot name="menu"
113-
class="${classMap({ show: expanded })}"
114-
?hidden="${!this.expanded}"
115-
@focusout="${this.#onMenuFocusout}"
116-
@keydown="${this.#onMenuKeydown}"
117-
@click="${this.#onSelect}">
118-
<pf-dropdown-menu id="menu"
119-
part="menu"
120-
?disabled="${disabled}">
121-
<slot></slot>
122-
</pf-dropdown-menu>
123-
</slot>
124-
</div>`;
102+
<div class="${classMap({ expanded, [anchor ?? '']: !!anchor, [alignment ?? '']: !!alignment })}"
103+
style="${styleMap(styles)}"
104+
@slotchange="${this.#onSlotchange}">
105+
<slot name="trigger"
106+
@keydown="${this.#onButtonKeydown}"
107+
@click="${() => this.toggle()}">
108+
<pf-button variant="control"
109+
icon="caret-down"
110+
icon-set="fas">Dropdown</pf-button>
111+
</slot>
112+
<slot name="menu"
113+
?hidden="${!this.expanded}"
114+
@focusout="${this.#onMenuFocusout}"
115+
@keydown="${this.#onMenuKeydown}"
116+
@click="${this.#onSelect}">
117+
<pf-dropdown-menu id="menu"
118+
part="menu"
119+
?disabled="${disabled}">
120+
<slot></slot>
121+
</pf-dropdown-menu>
122+
</slot>
123+
</div>
124+
`;
125125
}
126126

127127
override firstUpdated() {

0 commit comments

Comments
 (0)