Skip to content

Commit 6a2ec4e

Browse files
committed
supprt undefined as return of renderExpandSymbol
1 parent 6b2ef37 commit 6a2ec4e

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

packages/uui-menu-item/lib/uui-menu-item.element.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
126126
* Overwrite the expand symbol rendering, this replaces the Expand Symbol from UI Library.
127127
*/
128128
@property({ attribute: false })
129-
public renderExpandSymbol?: () => Element | TemplateResult<1>;
129+
public renderExpandSymbol?: () => Element | TemplateResult<1> | undefined;
130130

131131
@state()
132132
private iconSlotHasContent = false;
@@ -229,11 +229,7 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
229229
id="caret-button"
230230
aria-label=${this.caretLabel}
231231
@click=${this._onCaretClicked}>
232-
${this.renderExpandSymbol
233-
? this.renderExpandSymbol()
234-
: html` <uui-symbol-expand
235-
aria-hidden="true"
236-
?open=${this.showChildren}></uui-symbol-expand>`}
232+
${this.#renderExpandSymbol()}
237233
</button>`
238234
: ''}
239235
${this.href && this.selectOnly !== true && this.selectable !== true
@@ -249,6 +245,18 @@ export class UUIMenuItemElement extends SelectOnlyMixin(
249245
`;
250246
}
251247

248+
#renderExpandSymbol() {
249+
if (this.renderExpandSymbol) {
250+
const result = this.renderExpandSymbol();
251+
if (result) {
252+
return result;
253+
}
254+
}
255+
256+
return html`<uui-symbol-expand
257+
.direction=${this.showChildren ? 'up' : 'down'}></uui-symbol-expand>`;
258+
}
259+
252260
static styles = [
253261
css`
254262
:host {

0 commit comments

Comments
 (0)