Skip to content

Commit

Permalink
Merge branch 'master' into fix/list/single-line
Browse files Browse the repository at this point in the history
  • Loading branch information
williamernest authored Aug 29, 2018
2 parents 510492e + 453b5c5 commit da0a983
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/mdc-select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ class MDCSelect extends MDCComponent {
this.nativeControl_.addEventListener('change', this.handleChange_);
this.nativeControl_.addEventListener('focus', this.handleFocus_);
this.nativeControl_.addEventListener('blur', this.handleBlur_);
['mousedown', 'touchstart'].forEach((evtType) => {
this.nativeControl_.addEventListener(evtType, this.handleClick_);
});

if (this.lineRipple_) {
['mousedown', 'touchstart'].forEach((evtType) => {
this.nativeControl_.addEventListener(evtType, this.handleClick_);
});
}

// Initially sync floating label
this.foundation_.handleChange();
Expand Down
13 changes: 13 additions & 0 deletions test/unit/mdc-select/mdc-select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,19 @@ test('mousedown on the select sets the line ripple origin', () => {
td.verify(bottomLine.setRippleCenter(200), {times: 1});
});

test('mousedown on the select does nothing if the it does not have a lineRipple', () => {
const hasOutline = true;
const {bottomLine, fixture} = setupTest(hasOutline);
const event = document.createEvent('MouseEvent');
const clientX = 200;
const clientY = 200;
// IE11 mousedown event.
event.initMouseEvent('mousedown', true, true, window, 0, 0, 0, clientX, clientY, false, false, false, false, 0, null);
fixture.querySelector('select').dispatchEvent(event);

td.verify(bottomLine.setRippleCenter(200), {times: 0});
});

test('#destroy removes the mousedown listener', () => {
const {bottomLine, component, fixture} = setupTest();
const event = document.createEvent('MouseEvent');
Expand Down

0 comments on commit da0a983

Please sign in to comment.