Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 798108b

Browse files
kfranqueiroKenneth G. Franqueiro
authored andcommitted
feat(drawer): Make list instance publicly accessible (#4516)
(cherry picked from commit f46941c)
1 parent 089a331 commit 798108b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/mdc-drawer/component.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export class MDCDrawer extends MDCComponent<MDCDismissibleDrawerFoundation> {
6868
private handleKeydown_!: SpecificEventListener<'keydown'>; // initialized in initialSyncWithDOM()
6969
private handleTransitionEnd_!: SpecificEventListener<'transitionend'>; // initialized in initialSyncWithDOM()
7070

71+
get list(): MDCList | undefined {
72+
return this.list_;
73+
}
74+
7175
initialize(
7276
focusTrapFactory: MDCDrawerFocusTrapFactory = createFocusTrap as unknown as MDCDrawerFocusTrapFactory,
7377
listFactory: MDCListFactory = (el) => new MDCList(el),

test/unit/mdc-drawer/mdc-drawer.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import td from 'testdouble';
2828

2929
import {MDCDrawer} from '../../../packages/mdc-drawer/index';
3030
import {strings, cssClasses} from '../../../packages/mdc-drawer/constants';
31-
import {MDCListFoundation} from '../../../packages/mdc-list/index';
31+
import {MDCList, MDCListFoundation} from '../../../packages/mdc-list/index';
3232
import {MDCDismissibleDrawerFoundation} from '../../../packages/mdc-drawer/dismissible/foundation';
3333
import {MDCModalDrawerFoundation} from '../../../packages/mdc-drawer/modal/foundation';
3434

@@ -150,6 +150,11 @@ test('#set open false calls foundation.close', () => {
150150
td.verify(mockFoundation.close(), {times: 1});
151151
});
152152

153+
test('#get list returns MDCList instance when DOM includes list', () => {
154+
const {component} = setupTest();
155+
assert.instanceOf(component.list, MDCList);
156+
});
157+
153158
test('click event calls foundation.handleScrimClick method', () => {
154159
const {root, mockFoundation} = setupTestWithMocks({variantClass: cssClasses.MODAL});
155160
const scrimEl = root.querySelector('.mdc-drawer-scrim');

0 commit comments

Comments
 (0)