Skip to content

Commit 5930f1a

Browse files
committed
fix
1 parent 8da4388 commit 5930f1a

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

.changeset/lucky-bobcats-hope.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@scouterna/ui-webc": major
3+
---
4+
5+
New component Drawer

packages/ui-webc/src/components/drawer/drawer.tsx

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ const exitIcon =
2626
export class ScoutDrawer implements ComponentInterface {
2727
@Element() rootElement: HTMLElement;
2828
/**
29-
* Open/closestate of the drawer.
29+
* Open/close state of the drawer.
3030
*/
3131
@Prop() open: boolean = false;
3232
/**
33-
* Open/close state of the drawer.
33+
* Heading within the sheet.
3434
*/
3535
@Prop() heading: string = "";
3636
/**
@@ -46,11 +46,11 @@ export class ScoutDrawer implements ComponentInterface {
4646
*/
4747
@Prop() showExitButton: boolean = false;
4848
/**
49-
* Back button label.
49+
* Exit button label.
5050
*/
5151
@Prop() exitButtonLabel: string = "";
5252
/**
53-
* Disable backdrop for the drawer. Will also make it clickable to close the drawer.
53+
* Disable backdrop for the drawer.
5454
*/
5555
@Prop() disableBackdrop: boolean = false;
5656

@@ -65,6 +65,9 @@ export class ScoutDrawer implements ComponentInterface {
6565
componentWillLoad(): Promise<void> | void {
6666
this.focusedNode = document.activeElement;
6767
}
68+
componentDidLoad(): void {
69+
this.setDrawerOpenState(true);
70+
}
6871
disconnectedCallback(): void {
6972
this.focusedNode;
7073
}
@@ -86,10 +89,14 @@ export class ScoutDrawer implements ComponentInterface {
8689
}
8790

8891
@Watch("open")
89-
setDialogOpenState(open: boolean) {
92+
setDrawerOpenState(open: boolean) {
9093
const drawer = this.rootElement.shadowRoot.querySelector(
9194
".drawer--container",
92-
) as HTMLElement;
95+
) as HTMLElement | null;
96+
97+
if (!drawer) {
98+
this.drawerState = open ? "opening" : "closing";
99+
}
93100
if (open) {
94101
this.drawerState = "opening";
95102
focusLock.on(drawer);
@@ -134,28 +141,26 @@ export class ScoutDrawer implements ComponentInterface {
134141
{shouldRenderHeader && (
135142
<div class="header--wrapper">
136143
{this.showBackButton && (
137-
// biome-ignore lint/a11y/useButtonType: <not needed>
138144
<button
145+
type="button"
139146
class="back-button"
140147
onClick={() => this.onBackButtonClick()}
141148
>
142-
<span class="icon" innerHTML={backIcon}>
143-
<span class="visually-hidden">{this.backButtonLabel}</span>
144-
</span>
149+
<span class="icon" innerHTML={backIcon}></span>
150+
<span class="visually-hidden">{this.backButtonLabel}</span>
145151
</button>
146152
)}
147153
{this.showExitButton && (
148-
// biome-ignore lint/a11y/useButtonType: <not needed>
149154
<button
155+
type="button"
150156
class="exit-button"
151157
onClick={() => this.onExitButtonClick()}
152158
>
153-
<span class="icon" innerHTML={exitIcon}>
154-
<span class="visually-hidden">{this.exitButtonLabel}</span>
155-
</span>
159+
<span class="icon" innerHTML={exitIcon}></span>
160+
<span class="visually-hidden">{this.exitButtonLabel}</span>
156161
</button>
157162
)}
158-
{this.heading && <h3 class="title">{this.heading}</h3>}
163+
{this.heading && <h3 class="heading">{this.heading}</h3>}
159164
</div>
160165
)}
161166
<div class={!this.disableContentPadding && `content--wrapper`}>

0 commit comments

Comments
 (0)