Skip to content

Commit

Permalink
fix(color-area): up and down arrows now work properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Najika Yoo authored and najikahalsema committed Mar 24, 2021
1 parent d75bbeb commit 44b9f74
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/color-area/src/ColorArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { TinyColor } from '@ctrl/tinycolor';

import styles from './color-area.css.js';

const preventDefault = (event: KeyboardEvent) => event.preventDefault();

/**
* @element sp-color-area
*/
Expand Down Expand Up @@ -197,11 +199,11 @@ export class ColorArea extends SpectrumElement {
switch (code) {
case 'ArrowUp':
case 'Up':
deltaY = -this.step;
deltaY = this.step * -1;
break;
case 'ArrowDown':
case 'Down':
deltaY = this.step;
deltaY = this.step * 1;
break;
case 'ArrowLeft':
case 'Left':
Expand Down Expand Up @@ -388,7 +390,7 @@ export class ColorArea extends SpectrumElement {
step=${this.step}
.value=${String(this.x)}
@input=${this.handleInput}
@keyup=${(event: KeyboardEvent) => event.preventDefault()}
@keydown=${preventDefault}
/>
<input
type="range"
Expand All @@ -400,7 +402,7 @@ export class ColorArea extends SpectrumElement {
step=${this.step}
.value=${String(this.y)}
@input=${this.handleInput}
@keyup=${(event: KeyboardEvent) => event.preventDefault()}
@keydown=${preventDefault}
/>
`;
}
Expand Down

0 comments on commit 44b9f74

Please # to comment.