Skip to content

refactor(material/sort): explicit sort direction #23632

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/material/sort/sort-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class MatSortHeader
@Input() arrowPosition: 'before' | 'after' = 'after';

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

/**
* Description applied to MatSortHeader's button element with aria-describedby. This text should
Expand Down
6 changes: 3 additions & 3 deletions src/material/sort/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface MatSortable {
id: string;

/** Starting sort direction. */
start: 'asc' | 'desc';
start: SortDirection;

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

/** The sort direction of the currently active MatSortable. */
@Input('matSortDirection')
Expand Down Expand Up @@ -203,7 +203,7 @@ export class MatSort
}

/** Returns the sort direction cycle to use given the provided parameters of order and clear. */
function getSortDirectionCycle(start: 'asc' | 'desc', disableClear: boolean): SortDirection[] {
function getSortDirectionCycle(start: SortDirection, disableClear: boolean): SortDirection[] {
let sortOrder: SortDirection[] = ['asc', 'desc'];
if (start == 'desc') {
sortOrder.reverse();
Expand Down
6 changes: 3 additions & 3 deletions tools/public_api_guard/material/sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class MatSort extends _MatSortBase implements CanDisable, HasInitialized,
sort(sortable: MatSortable): void;
sortables: Map<string, MatSortable>;
readonly sortChange: EventEmitter<Sort>;
start: 'asc' | 'desc';
start: SortDirection;
readonly _stateChanges: Subject<void>;
// (undocumented)
static ɵdir: i0.ɵɵDirectiveDeclaration<MatSort, "[matSort]", ["matSort"], { "disabled": "matSortDisabled"; "active": "matSortActive"; "start": "matSortStart"; "direction": "matSortDirection"; "disableClear": "matSortDisableClear"; }, { "sortChange": "matSortChange"; }, never>;
Expand All @@ -82,7 +82,7 @@ export class MatSort extends _MatSortBase implements CanDisable, HasInitialized,
export interface MatSortable {
disableClear: boolean;
id: string;
start: 'asc' | 'desc';
start: SortDirection;
}

// @public
Expand Down Expand Up @@ -139,7 +139,7 @@ export class MatSortHeader extends _MatSortHeaderBase implements CanDisable, Mat
_sort: MatSort;
get sortActionDescription(): string;
set sortActionDescription(value: string);
start: 'asc' | 'desc';
start: SortDirection;
_toggleOnInteraction(): void;
_updateArrowDirection(): void;
_viewState: ArrowViewStateTransition;
Expand Down