Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Jun 8, 2017
1 parent 2ce96d3 commit d139648
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/lib/core/option/optgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class MdOptgroupBase { }
export const _MdOptgroupMixinBase = mixinDisabled(MdOptgroupBase);

// Counter for unique group ids.
let nextId = 0;
let _uniqueOptgroupIdCounter = 0;

/**
* Component that is used to group instances of `md-option`.
Expand All @@ -30,5 +30,5 @@ export class MdOptgroup extends _MdOptgroupMixinBase implements CanDisable {
@Input() label: string;

/** Unique id for the underlying label. */
_labelId: string = `mat-optgroup-label-${nextId++}`;
_labelId: string = `mat-optgroup-label-${_uniqueOptgroupIdCounter++}`;
}
8 changes: 4 additions & 4 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -768,15 +768,15 @@ export class MdSelect extends _MdSelectMixinBase implements AfterContentInit, On
const maxScroll = scrollContainerHeight - panelHeight;

if (this._selectionModel.hasValue()) {
let selectedIndex = this._getOptionIndex(this._selectionModel.selected[0]);
let selectedOptionOffset = this._getOptionIndex(this._selectionModel.selected[0]);

selectedIndex += this._getLabelCountBeforeOption(selectedIndex);
selectedOptionOffset += this._getLabelCountBeforeOption(selectedOptionOffset);

// We must maintain a scroll buffer so the selected option will be scrolled to the
// center of the overlay panel rather than the top.
const scrollBuffer = panelHeight / 2;
this._scrollTop = this._calculateOverlayScroll(selectedIndex, scrollBuffer, maxScroll);
this._offsetY = this._calculateOverlayOffsetY(selectedIndex, scrollBuffer, maxScroll);
this._scrollTop = this._calculateOverlayScroll(selectedOptionOffset, scrollBuffer, maxScroll);
this._offsetY = this._calculateOverlayOffsetY(selectedOptionOffset, scrollBuffer, maxScroll);
} else {
// If no option is selected, the panel centers on the first option. In this case,
// we must only adjust for the height difference between the option element
Expand Down

0 comments on commit d139648

Please sign in to comment.