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

Method getNextSortDirection

src/material/sort/sort.ts:173–189  ·  view source on GitHub ↗

Returns the next sort direction of the active sortable, checking for potential overrides.

(sortable: MatSortable)

Source from the content-addressed store, hash-verified

171
172 /** Returns the next sort direction of the active sortable, checking for potential overrides. */
173 getNextSortDirection(sortable: MatSortable): SortDirection {
174 if (!sortable) {
175 return '';
176 }
177
178 // Get the sort direction cycle with the potential sortable overrides.
179 const disableClear =
180 sortable?.disableClear ?? this.disableClear ?? !!this._defaultOptions?.disableClear;
181 let sortDirectionCycle = getSortDirectionCycle(sortable.start || this.start, disableClear);
182
183 // Get and return the next direction in the cycle
184 let nextDirectionIndex = sortDirectionCycle.indexOf(this.direction) + 1;
185 if (nextDirectionIndex >= sortDirectionCycle.length) {
186 nextDirectionIndex = 0;
187 }
188 return sortDirectionCycle[nextDirectionIndex];
189 }
190
191 ngOnInit() {
192 this._initializedStream.next();

Callers 1

sortMethod · 0.95

Calls 1

getSortDirectionCycleFunction · 0.85

Tested by

no test coverage detected