Skip to content

Commit

Permalink
fix(button): fix ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
Enlcxx committed Nov 23, 2018
1 parent 28f5088 commit 5e5aede
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/lib/button/button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,22 @@ export class LyButton extends LyButtonMixinBase implements OnChanges, OnInit, Af
if (this.disableRipple === null) {
this.disableRipple = DEFAULT_DISABLE_RIPPLE;
}
this._focusState.listen(this._el).subscribe((event) => {
if (this._onFocusByKeyboardState === true) {
this._renderer.removeClass(this._el.nativeElement, this.classes.onFocusByKeyboard);
this._onFocusByKeyboardState = false;
}
if (event.by === 'keyboard') {
if (event.event.type === 'focus') {
this._onFocusByKeyboardState = true;
this._renderer.addClass(this._el.nativeElement, this.classes.onFocusByKeyboard);

const focusState = this._focusState.listen(this._el);
if (focusState) {
focusState.subscribe((event) => {
if (this._onFocusByKeyboardState === true) {
this._renderer.removeClass(this._el.nativeElement, this.classes.onFocusByKeyboard);
this._onFocusByKeyboardState = false;
}
}
});
if (event.by === 'keyboard') {
if (event.event.type === 'focus') {
this._onFocusByKeyboardState = true;
this._renderer.addClass(this._el.nativeElement, this.classes.onFocusByKeyboard);
}
}
});
}
}

public focus() {
Expand Down

0 comments on commit 5e5aede

Please sign in to comment.