ngx-material-keyboard / core

Onscreen virtual keyboard for Angular ≥ 5 (https://angular.io/) using Angular Material (https://material.angular.io/).
https://ngx-material-keyboard.github.io/core/
98 stars 120 forks source link

isOpen variable not changing until DOM change #46

Open connollykeyjoint opened 6 years ago

connollykeyjoint commented 6 years ago

I am attempting to listen to the isOpen variable as per the demo code

get keyboardVisible(): boolean {
    return this._keyboardService.isOpened;
}

But the value does not appear to change when the keyboard has finished exiting but when the next DOM event happens after the exit.

davidenke commented 6 years ago

How did You check the value change? Output to the DOM? Have you logged smth.?

davidenke commented 6 years ago

What I mean is: Maybe You just have to kick start a new change detection cycle using ChangeDetectorRef.detectChanges()...

connollykeyjoint commented 6 years ago

Yes, I logged to the console.

I can see the change when the keyboard is opened using the code:

get keyboardVisible(): boolean {
    console.log('Opened? ' + this._keyboardService.isOpened);
    return this._keyboardService.isOpened;
}

But the value does not change to false after the keyboard has exited until there is another DOM i.e. button clicked.

I have tried your solution regarding ChangeDetectorRef.detectChanges(). This does trigger the change but I have to set a timeout event but of course, the best solution would be to have the event triggered once the keyboard has finished exiting.

connollykeyjoint commented 6 years ago

Upon research of the code, it appears that you are calling the change event on enter() but not on exit().

https://github.com/ngx-material-keyboard/core/blob/b9e750cd98ef77678239bd5bdb3ffd67305cc5b3/src/core/src/components/keyboard-container/keyboard-container.component.ts#L114-L120

https://github.com/ngx-material-keyboard/core/blob/b9e750cd98ef77678239bd5bdb3ffd67305cc5b3/src/core/src/components/keyboard-container/keyboard-container.component.ts#L122-L126