Skip to content

Commit 0961fe7

Browse files
authored
Allow banners to have no action buttons
Without that, the FocusTrap complains it has no focusable child (which it won't have if the user decides to not include the "actions" slot).
1 parent 9431254 commit 0961fe7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/banner/src/Banner.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,10 @@
134134
}
135135
136136
onMount(() => {
137-
focusTrap = new FocusTrap(element, {
138-
initialFocusEl: getPrimaryActionEl(),
139-
});
137+
let initialFocusEl = getPrimaryActionEl();
138+
if (initialFocusEl) {
139+
focusTrap = new FocusTrap(element, { initialFocusEl });
140+
}
140141
141142
instance = new MDCBannerFoundation({
142143
addClass,

0 commit comments

Comments
 (0)