From 4b05da1b37a8ec1a65d77bf06954508b204e9b20 Mon Sep 17 00:00:00 2001 From: Max Okorokov Date: Tue, 4 Dec 2018 16:08:59 +0100 Subject: [PATCH] fix(rating): don't hijack Tab key navigation Broken since #2473, we prevent default ALL known keys from Key enum Fixes #2895 --- src/rating/rating.ts | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/rating/rating.ts b/src/rating/rating.ts index d961487b29..f629c31810 100644 --- a/src/rating/rating.ts +++ b/src/rating/rating.ts @@ -13,7 +13,7 @@ import { ChangeDetectorRef } from '@angular/core'; import {NgbRatingConfig} from './rating-config'; -import {toString, getValueInRange} from '../util/util'; +import {getValueInRange} from '../util/util'; import {Key} from '../util/key'; import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms'; @@ -142,27 +142,27 @@ export class NgbRating implements ControlValueAccessor, handleKeyDown(event: KeyboardEvent) { // tslint:disable-next-line:deprecation - const {which} = event; - if (Key[toString(which)]) { - event.preventDefault(); - - switch (which) { - case Key.ArrowDown: - case Key.ArrowLeft: - this.update(this.rate - 1); - break; - case Key.ArrowUp: - case Key.ArrowRight: - this.update(this.rate + 1); - break; - case Key.Home: - this.update(0); - break; - case Key.End: - this.update(this.max); - break; - } + switch (event.which) { + case Key.ArrowDown: + case Key.ArrowLeft: + this.update(this.rate - 1); + break; + case Key.ArrowUp: + case Key.ArrowRight: + this.update(this.rate + 1); + break; + case Key.Home: + this.update(0); + break; + case Key.End: + this.update(this.max); + break; + default: + return; } + + // note 'return' in default case + event.preventDefault(); } ngOnChanges(changes: SimpleChanges) {