Skip to content

Commit

Permalink
fix(admin-ui): Improve keyboard controls for data table filters
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jun 30, 2023
1 parent f5dfc2f commit 00f0155
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<clr-icon shape="times" size="12"></clr-icon>
</button>
<button vdrDropdownTrigger class="">
<span *ngIf="state === 'new'">{{ 'common.add-filter' | translate }}</span>
<span *ngIf="state === 'new'">{{ 'common.add-filter' | translate }} <span class="filter-hotkey">f</span></span>
<span *ngIf="state === 'active'">
<vdr-data-table-filter-label
[filterWithValue]="filterWithValue"
Expand All @@ -30,7 +30,7 @@
<div class="mx-2 mt-1">
<div vdrCustomFilterComponentHost #customComponentHost></div>
</div>
<div *ngIf="selectedFilter" class="">
<form *ngIf="selectedFilter" class="" [cdkTrapFocus]="true" [cdkTrapFocusAutoCapture]="true">
<ng-container *ngIf="selectedFilter.type.kind !== 'custom'">
<div class="mx-2 mt-1" [ngSwitch]="selectedFilter.type.kind">
<div *ngSwitchCase="'select'" [formGroup]="formControl">
Expand Down Expand Up @@ -104,6 +104,6 @@
<clr-icon shape="check"></clr-icon>
</button>
</div>
</div>
</form>
</vdr-dropdown-menu>
</vdr-dropdown>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
border-radius: var(--border-radius-lg);
background-color: var(--color-button-small-bg);
color: var(--color-button-small-text);

> button {
border: none;
gap: 12px;
Expand All @@ -24,13 +25,16 @@
border-radius: var(--border-radius-lg);
color: var(--color-button-small-text);
}

&.active {
background-color: var(--color-primary-700);
color: var(--color-primary-100);

> button {
color: var(--color-primary-100);
}
}

button.remove {
}
}
Expand All @@ -48,8 +52,20 @@ label {
color: var(--color-weight-600);
margin: 0 calc(var(--space-unit) * 2);
}

.apply-wrapper {
display: flex;
justify-content: flex-end;
padding-right : calc(var(--space-unit) * 2);
padding-right: calc(var(--space-unit) * 2);
}

.filter-hotkey {
font-size: var(--font-size-xs);
color: var(--color-weight-500);
border: 1px solid var(--color-weight-200);
background-color: var(--color-weight-100);
border-radius: var(--border-radius);
padding: 0 3px;
text-transform: uppercase;
margin-inline-start: 3px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ChangeDetectorRef,
Component,
ComponentRef,
HostListener,
Input,
ViewChild,
} from '@angular/core';
Expand Down Expand Up @@ -40,6 +41,13 @@ export class DataTableFiltersComponent implements AfterViewInit {
protected selectedFilter: DataTableFilter | undefined;
protected customComponent?: ComponentRef<FormInputComponent>;

@HostListener('window:keydown.f', ['$event'])
onFKeyPress(event: KeyboardEvent) {
if (!this.dropdown.isOpen && this.state === 'new') {
this.dropdown.toggleOpen();
}
}

constructor(private i18nService: I18nService, private changeDetectorRef: ChangeDetectorRef) {}

ngAfterViewInit() {
Expand Down

0 comments on commit 00f0155

Please sign in to comment.