Skip to content

Commit 37db2d5

Browse files
authored
refactor(material/sort): explicit sort direction (#23632)
1 parent 4e5e286 commit 37db2d5

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/material/sort/sort-header.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class MatSortHeader
143143
@Input() arrowPosition: SortHeaderArrowPosition = 'after';
144144

145145
/** Overrides the sort start value of the containing MatSort for this MatSortable. */
146-
@Input() start: 'asc' | 'desc';
146+
@Input() start: SortDirection;
147147

148148
/**
149149
* Description applied to MatSortHeader's button element with aria-describedby. This text should

src/material/sort/sort.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface MatSortable {
3737
id: string;
3838

3939
/** Starting sort direction. */
40-
start: 'asc' | 'desc';
40+
start: SortDirection;
4141

4242
/** Whether to disable clearing the sorting state. */
4343
disableClear: boolean;
@@ -93,7 +93,7 @@ export class MatSort
9393
* The direction to set when an MatSortable is initially sorted.
9494
* May be overriden by the MatSortable's sort start.
9595
*/
96-
@Input('matSortStart') start: 'asc' | 'desc' = 'asc';
96+
@Input('matSortStart') start: SortDirection = 'asc';
9797

9898
/** The sort direction of the currently active MatSortable. */
9999
@Input('matSortDirection')
@@ -208,7 +208,7 @@ export class MatSort
208208
}
209209

210210
/** Returns the sort direction cycle to use given the provided parameters of order and clear. */
211-
function getSortDirectionCycle(start: 'asc' | 'desc', disableClear: boolean): SortDirection[] {
211+
function getSortDirectionCycle(start: SortDirection, disableClear: boolean): SortDirection[] {
212212
let sortOrder: SortDirection[] = ['asc', 'desc'];
213213
if (start == 'desc') {
214214
sortOrder.reverse();

tools/public_api_guard/material/sort.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class MatSort extends _MatSortBase implements CanDisable, HasInitialized,
7070
sort(sortable: MatSortable): void;
7171
sortables: Map<string, MatSortable>;
7272
readonly sortChange: EventEmitter<Sort>;
73-
start: 'asc' | 'desc';
73+
start: SortDirection;
7474
readonly _stateChanges: Subject<void>;
7575
// (undocumented)
7676
static ɵdir: i0.ɵɵDirectiveDeclaration<MatSort, "[matSort]", ["matSort"], { "disabled": "matSortDisabled"; "active": "matSortActive"; "start": "matSortStart"; "direction": "matSortDirection"; "disableClear": "matSortDisableClear"; }, { "sortChange": "matSortChange"; }, never, never, false>;
@@ -82,7 +82,7 @@ export class MatSort extends _MatSortBase implements CanDisable, HasInitialized,
8282
export interface MatSortable {
8383
disableClear: boolean;
8484
id: string;
85-
start: 'asc' | 'desc';
85+
start: SortDirection;
8686
}
8787

8888
// @public
@@ -140,7 +140,7 @@ export class MatSortHeader extends _MatSortHeaderBase implements CanDisable, Mat
140140
_sort: MatSort;
141141
get sortActionDescription(): string;
142142
set sortActionDescription(value: string);
143-
start: 'asc' | 'desc';
143+
start: SortDirection;
144144
_toggleOnInteraction(): void;
145145
_updateArrowDirection(): void;
146146
_viewState: ArrowViewStateTransition;

0 commit comments

Comments
 (0)