Skip to content

Commit

Permalink
Merge branch 'next' into f/fix-dropdown-hints
Browse files Browse the repository at this point in the history
  • Loading branch information
cablke01 authored Dec 2, 2022
2 parents 1f62873 + 5ee7db1 commit f3d29a3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
11 changes: 9 additions & 2 deletions projects/novo-elements/src/elements/button/Button.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// NG2
import { ChangeDetectionStrategy, Component, ElementRef, HostBinding, Input } from '@angular/core';
import { BooleanInput } from '../../utils/decorators';
import { ChangeDetectionStrategy, Component, ElementRef, HostBinding, HostListener, Input } from '@angular/core';
import { BooleanInput, Helpers, Key } from '../../utils';

@Component({
selector: 'novo-button,button[theme]',
Expand Down Expand Up @@ -111,6 +111,13 @@ export class NovoButtonElement {

constructor(public element: ElementRef) {}

@HostListener('keydown', ['$event'])
handleKeydown(event: KeyboardEvent) {
if ((Key.Enter === event.key || Key.Space === event.key) && (this.disabled || this.loading)) {
Helpers.swallowEvent(event);
}
}

/** Focuses the input. */
focus(options?: FocusOptions): void {
this.element.nativeElement.focus(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export class ButtonDynamicExample {
changeTheme() {
const i = Math.floor(Math.random() * 4);
this.theme = ['primary', 'secondary', 'dialogue', 'standard', 'icon'][i];
console.log('changed theme to', this.theme);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class ButtonLoadingExample {
loading: boolean = false;
loadingButtonText: string = 'Delete';
fakeRequest() {
console.log('making fake request');
this.loading = true;
this.loadingButtonText = this.loading ? 'Removing... ' : 'Delete';
setTimeout(() => {
Expand Down

0 comments on commit f3d29a3

Please sign in to comment.