79730: Don't submit date slider changes until keyup

This commit is contained in:
Yura Bondarenko
2021-06-01 15:20:33 +02:00
parent 6e95990431
commit c60fa2c441
2 changed files with 20 additions and 1 deletions

View File

@@ -32,7 +32,8 @@
<ng-container *ngIf="shouldShowSlider()">
<nouislider [connect]="true" [min]="min" [max]="max" [step]="1"
[dsDebounce]="500" (onDebounce)="onSubmit()"
[dsDebounce]="250" (onDebounce)="onSubmit()"
(keydown)="startKeyboardControl()" (keyup)="stopKeyboardControl()"
[(ngModel)]="range" ngDefaultControl>
</nouislider>
</ng-container>

View File

@@ -68,6 +68,12 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
*/
sub: Subscription;
/**
* Whether the sider is being controlled by the keyboard.
* Supresses any changes until the key is released.
*/
keyboardControl: boolean;
constructor(protected searchService: SearchService,
protected filterService: SearchFilterService,
protected router: Router,
@@ -104,6 +110,10 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
* Submits new custom range values to the range filter from the widget
*/
onSubmit() {
if (this.keyboardControl) {
return; // don't submit if a key is being held down
}
const newMin = this.range[0] !== this.min ? [this.range[0]] : null;
const newMax = this.range[1] !== this.max ? [this.range[1]] : null;
this.router.navigate(this.getSearchLinkParts(), {
@@ -117,6 +127,14 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
this.filter = '';
}
startKeyboardControl(): void {
this.keyboardControl = true;
}
stopKeyboardControl(): void {
this.keyboardControl = false;
}
/**
* TODO when upgrading nouislider, verify that this check is still needed.
* Prevents AoT bug