Skip to content

Commit d180ee3

Browse files
committed
fix: modal drawer absolute positioning
1 parent d9db919 commit d180ee3

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

packages/drawer/Drawer.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'mdc-drawer': true,
88
'mdc-drawer--dismissible': variant === 'dismissible',
99
'mdc-drawer--modal': variant === 'modal',
10-
'smui-drawer__static': !fixed,
10+
'smui-drawer__absolute': variant === 'modal' && !fixed,
1111
...internalClasses,
1212
})}
1313
on:keydown={(event) => instance && instance.handleKeydown(event)}

packages/drawer/_style.scss

+1-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44
@include drawer.dismissible-core-styles;
55
@include drawer.modal-core-styles;
66

7-
.mdc-drawer.smui-drawer__static {
8-
position: static;
9-
}
10-
7+
.mdc-drawer.smui-drawer__absolute,
118
.mdc-drawer-scrim.smui-drawer-scrim__absolute {
129
position: absolute;
1310
}

site/src/routes/demo/drawer.svelte

+15-16
Original file line numberDiff line numberDiff line change
@@ -75,35 +75,35 @@
7575
<List>
7676
<Item
7777
href="javascript:void(0)"
78-
on:click={() => setActive('Gray Kittens')}
78+
on:click={() => setActiveDismissible('Gray Kittens')}
7979
activated={active === 'Gray Kittens'}
8080
>
8181
<Text>Gray Kittens</Text>
8282
</Item>
8383
<Item
8484
href="javascript:void(0)"
85-
on:click={() => setActive('A Space Rocket')}
85+
on:click={() => setActiveDismissible('A Space Rocket')}
8686
activated={active === 'A Space Rocket'}
8787
>
8888
<Text>A Space Rocket</Text>
8989
</Item>
9090
<Item
9191
href="javascript:void(0)"
92-
on:click={() => setActive('100 Pounds of Gravel')}
92+
on:click={() => setActiveDismissible('100 Pounds of Gravel')}
9393
activated={active === '100 Pounds of Gravel'}
9494
>
9595
<Text>100 Pounds of Gravel</Text>
9696
</Item>
9797
<Item
9898
href="javascript:void(0)"
99-
on:click={() => setActive('All of the Shrimp')}
99+
on:click={() => setActiveDismissible('All of the Shrimp')}
100100
activated={active === 'All of the Shrimp'}
101101
>
102102
<Text>All of the Shrimp</Text>
103103
</Item>
104104
<Item
105105
href="javascript:void(0)"
106-
on:click={() => setActive('A Planet with a Mall')}
106+
on:click={() => setActiveDismissible('A Planet with a Mall')}
107107
activated={active === 'A Planet with a Mall'}
108108
>
109109
<Text>A Planet with a Mall</Text>
@@ -132,7 +132,7 @@
132132

133133
<div class="drawer-container">
134134
<!-- Don't include fixed={false} if this is a page wide drawer.
135-
It adds a style for static positioning. -->
135+
It adds a style for absolute positioning. -->
136136
<Drawer
137137
variant="modal"
138138
fixed={false}
@@ -147,31 +147,31 @@
147147
<List>
148148
<Item
149149
href="javascript:void(0)"
150-
on:click={() => setActive2('Inbox')}
150+
on:click={() => setActiveModal('Inbox')}
151151
activated={active2 === 'Inbox'}
152152
>
153153
<Graphic class="material-icons" aria-hidden="true">inbox</Graphic>
154154
<Text>Inbox</Text>
155155
</Item>
156156
<Item
157157
href="javascript:void(0)"
158-
on:click={() => setActive2('Star')}
158+
on:click={() => setActiveModal('Star')}
159159
activated={active2 === 'Star'}
160160
>
161161
<Graphic class="material-icons" aria-hidden="true">star</Graphic>
162162
<Text>Star</Text>
163163
</Item>
164164
<Item
165165
href="javascript:void(0)"
166-
on:click={() => setActive2('Sent Mail')}
166+
on:click={() => setActiveModal('Sent Mail')}
167167
activated={active2 === 'Sent Mail'}
168168
>
169169
<Graphic class="material-icons" aria-hidden="true">send</Graphic>
170170
<Text>Sent Mail</Text>
171171
</Item>
172172
<Item
173173
href="javascript:void(0)"
174-
on:click={() => setActive2('Drafts')}
174+
on:click={() => setActiveModal('Drafts')}
175175
activated={active2 === 'Drafts'}
176176
>
177177
<Graphic class="material-icons" aria-hidden="true">drafts</Graphic
@@ -183,7 +183,7 @@
183183
<Subheader component={H6}>Labels</Subheader>
184184
<Item
185185
href="javascript:void(0)"
186-
on:click={() => setActive2('Family')}
186+
on:click={() => setActiveModal('Family')}
187187
activated={active2 === 'Family'}
188188
>
189189
<Graphic class="material-icons" aria-hidden="true"
@@ -193,7 +193,7 @@
193193
</Item>
194194
<Item
195195
href="javascript:void(0)"
196-
on:click={() => setActive2('Friends')}
196+
on:click={() => setActiveModal('Friends')}
197197
activated={active2 === 'Friends'}
198198
>
199199
<Graphic class="material-icons" aria-hidden="true"
@@ -203,7 +203,7 @@
203203
</Item>
204204
<Item
205205
href="javascript:void(0)"
206-
on:click={() => setActive2('Work')}
206+
on:click={() => setActiveModal('Work')}
207207
activated={active2 === 'Work'}
208208
>
209209
<Graphic class="material-icons" aria-hidden="true"
@@ -254,12 +254,11 @@
254254
let myDrawer2Open = false;
255255
let active2 = 'Inbox';
256256
257-
function setActive(value) {
257+
function setActiveDismissible(value) {
258258
active = value;
259-
myDrawerOpen = false;
260259
}
261260
262-
function setActive2(value) {
261+
function setActiveModal(value) {
263262
active2 = value;
264263
myDrawer2Open = false;
265264
}

0 commit comments

Comments
 (0)