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

Commit

Permalink
fix(select): Enhanced select doesn't wrap focus (#4083)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhiomkar authored Nov 14, 2018
1 parent c814835 commit c640d50
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mdc-menu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ Property | Value Type | Description
`open` | Boolean | Proxies to the menu surface's `open` property.
`items` | Array<Element> | Proxies to the list to query for all `.mdc-list-item` elements.
`quickOpen` | Boolean | Proxies to the menu surface `quickOpen` property.
`wrapFocus` | Boolean | Proxies to list's `wrapFocus` property.

Method Signature | Description
--- | ---
Expand Down
10 changes: 10 additions & 0 deletions packages/mdc-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ class MDCMenu extends MDCComponent {
this.menuSurface_.open = value;
}

/** @return {boolean} */
get wrapFocus() {
return this.list_.wrapFocus;
}

/** @param {boolean} value */
set wrapFocus(value) {
this.list_.wrapFocus = value;
}

/**
* @param {!Corner} corner Default anchor corner alignment of top-left
* menu corner.
Expand Down
1 change: 1 addition & 0 deletions packages/mdc-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ class MDCSelect extends MDCComponent {
this.menu_.hoistMenuToBody();
this.menu_.setAnchorElement(/** @type {!HTMLElement} */ (this.root_));
this.menu_.setAnchorCorner(menuSurfaceConstants.Corner.BOTTOM_START);
this.menu_.wrapFocus = false;
}

/**
Expand Down
10 changes: 10 additions & 0 deletions test/unit/mdc-menu/mdc-menu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class FakeList {
this.root = root;
this.destroy = td.func('.destroy');
this.itemsContainer = td.func('.root_');
this.wrapFocus = true;
this.listElements = [].slice.call(root.querySelectorAll('.mdc-list-item'));
}
}
Expand Down Expand Up @@ -158,6 +159,15 @@ test('get/set open', () => {
assert.isFalse(menuSurface.open);
});

test('wrapFocus proxies to MDCList#wrapFocus property', () => {
const {component, list} = setupTestWithFakes();

assert.isTrue(component.wrapFocus);

component.wrapFocus = false;
assert.isFalse(list.wrapFocus);
});

test('setAnchorCorner proxies to the MDCMenuSurface#setAnchorCorner method', () => {
const {component, menuSurface} = setupTestWithFakes();
component.setAnchorCorner(Corner.TOP_START);
Expand Down

0 comments on commit c640d50

Please sign in to comment.