core icon indicating copy to clipboard operation
core copied to clipboard

isOpen variable not changing until DOM change

Open connollykeyjoint opened this issue 7 years ago • 4 comments

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.

connollykeyjoint avatar Feb 27 '18 05:02 connollykeyjoint

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

davidenke avatar Feb 27 '18 07:02 davidenke

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

davidenke avatar Feb 27 '18 07:02 davidenke

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 avatar Feb 27 '18 20:02 connollykeyjoint

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

connollykeyjoint avatar Feb 27 '18 21:02 connollykeyjoint