Skip to content

Commit

Permalink
fix: resolve unit test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Jun 14, 2017
1 parent 1f3301c commit 02c961b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/examples/select-header/select-header-example.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<md-select placeholder="Favorite food" [(ngModel)]="currentDrink" name="food" #select="mdSelect">
<md-select placeholder="Favorite food" [(ngModel)]="selectedValue" name="food" #select="mdSelect">
<md-select-header>
<input type="search" [(ngModel)]="searchString" role="combobox" [attr.aria-owns]="select.panelId"
(ngModelChange)="filterFoods()" placeholder="Search for food"/>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from '../core/placeholder/placeholder-options';


fdescribe('MdSelect', () => {
describe('MdSelect', () => {
let overlayContainerElement: HTMLElement;
let dir: {value: 'ltr'|'rtl'};
let scrolledSubject = new Subject();
Expand Down Expand Up @@ -983,7 +983,7 @@ fdescribe('MdSelect', () => {
trigger.click();
groupFixture.detectChanges();

const scrollContainer = document.querySelector('.cdk-overlay-pane .mat-select-panel');
const scrollContainer = document.querySelector('.cdk-overlay-pane .mat-select-content');

// The selected option should be scrolled to the center of the panel.
// This will be its original offset from the scrollTop - half the panel height + half the
Expand Down
6 changes: 2 additions & 4 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -802,9 +802,8 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
// we must only adjust for the height difference between the option element
// and the trigger element, then multiply it by -1 to ensure the panel moves
// in the correct direction up the page.
this._offsetY = (SELECT_ITEM_HEIGHT - SELECT_TRIGGER_HEIGHT) / 2 * -1;
// this._offsetY = (SELECT_OPTION_HEIGHT - SELECT_TRIGGER_HEIGHT) / 2 * -1 -
// (this.header ? SELECT_OPTION_HEIGHT : 0);
this._offsetY = (SELECT_ITEM_HEIGHT - SELECT_TRIGGER_HEIGHT) / 2 * -1 -
(this.header ? SELECT_ITEM_HEIGHT : 0);
}

this._checkOverlayWithinViewport(maxScroll);
Expand Down Expand Up @@ -958,7 +957,6 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
const panelHeightTop = Math.abs(this._offsetY);
const totalPanelHeight =
Math.min(this._getItemCount() * SELECT_ITEM_HEIGHT, SELECT_PANEL_MAX_HEIGHT);
// Math.min(this.options.length * SELECT_OPTION_HEIGHT, SELECT_PANEL_MAX_HEIGHT);
const panelHeightBottom = totalPanelHeight - panelHeightTop - triggerRect.height;

if (panelHeightBottom > bottomSpaceAvailable) {
Expand Down

0 comments on commit 02c961b

Please sign in to comment.