mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
79730: Don't submit date slider changes until keyup
This commit is contained in:
@@ -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>
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user