-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(select): add md-optgroup component #4432
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments from me, @kara should look at all of the positioning related stuff
templateUrl: 'optgroup.html', | ||
encapsulation: ViewEncapsulation.None, | ||
inputs: ['disabled'], | ||
host: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this should have role="group"
as well
src/lib/select/select.spec.ts
Outdated
@@ -735,7 +755,9 @@ describe('MdSelect', () => { | |||
* Asserts that the given option is aligned with the trigger. | |||
* @param index The index of the option. | |||
*/ | |||
function checkTriggerAlignedWithOption(index: number): void { | |||
function checkTriggerAlignedWithOption(index: number, selectInstance = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update existing jsdoc
src/lib/select/select.ts
Outdated
@@ -41,27 +41,30 @@ import 'rxjs/add/operator/startWith'; | |||
*/ | |||
|
|||
/** The fixed height of every option element. */ | |||
export const SELECT_OPTION_HEIGHT = 48; | |||
export const SELECT_ELEMENT_HEIGHT = 48; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SELECT_ITEM_HEIGHT
(where item captures both groups and options)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some nits. Looks like this needs a rebase now too (probably my fault, sorry). Apply merge label when ready.
src/lib/core/option/optgroup.ts
Outdated
export const _MdOptgroupMixinBase = mixinDisabled(MdOptgroupBase); | ||
|
||
// Counter for unique group ids. | ||
let nextId = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can we make this name more specific to optgroup?
|
||
/** The max height of the select's overlay panel */ | ||
export const SELECT_PANEL_MAX_HEIGHT = 256; | ||
|
||
/** The max number of options visible at once in the select panel. */ | ||
export const SELECT_MAX_OPTIONS_DISPLAYED = 5; | ||
export const SELECT_MAX_OPTIONS_DISPLAYED = | ||
Math.floor(SELECT_PANEL_MAX_HEIGHT / SELECT_ITEM_HEIGHT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why this is now calculated from the other two constants. I'm nitpicking because now that Math.floor has been added as a top-level function call, the right side will be retained after dead code elimination even if the constant is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I switched to computing it, because it's easy to forget if we ever decide to change any of the other constants.
src/lib/select/select.ts
Outdated
const selectedIndex = this._getOptionIndex(this._selectionModel.selected[0]); | ||
let selectedIndex = this._getOptionIndex(this._selectionModel.selected[0]); | ||
|
||
selectedIndex += this._getLabelCountBeforeOption(selectedIndex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since this isn't strictly the selectedIndex anymore, can we rename for clarity? selectedOffset
or something?
268a4e4
to
261fcb1
Compare
261fcb1
to
ca53217
Compare
Needs rebase |
Adds the `md-optgroup` component, which can be used to group options inside of `md-select`, in a similar way to the native `optgroup`. Fixes angular#3182.
ca53217
to
d139648
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Adds the
md-optgroup
component, which can be used to group options inside ofmd-select
, in a similar way to the nativeoptgroup
.Fixes #3182.