MCPcopy Create free account
hub / github.com/angular/components / _countGroupLabelsBeforeOption

Function _countGroupLabelsBeforeOption

src/material/core/option/option.ts:300–320  ·  view source on GitHub ↗
(
  optionIndex: number,
  options: QueryList<MatOption>,
  optionGroups: QueryList<MatOptgroup>,
)

Source from the content-addressed store, hash-verified

298 * @docs-private
299 */
300export function _countGroupLabelsBeforeOption(
301 optionIndex: number,
302 options: QueryList<MatOption>,
303 optionGroups: QueryList<MatOptgroup>,
304): number {
305 if (optionGroups.length) {
306 let optionsArray = options.toArray();
307 let groups = optionGroups.toArray();
308 let groupCounter = 0;
309
310 for (let i = 0; i < optionIndex + 1; i++) {
311 if (optionsArray[i].group && optionsArray[i].group === groups[groupCounter]) {
312 groupCounter++;
313 }
314 }
315
316 return groupCounter;
317 }
318
319 return 0;
320}
321
322/**
323 * Determines the position to which to scroll a panel in order for an option to be into view.

Callers 2

_scrollToOptionMethod · 0.90
_scrollOptionIntoViewMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected