Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a ngbtooltip to a ngbmodal #3130

Closed
LiamAjones opened this issue Apr 16, 2019 · 2 comments · Fixed by #3138
Closed

Adding a ngbtooltip to a ngbmodal #3130

LiamAjones opened this issue Apr 16, 2019 · 2 comments · Fixed by #3138

Comments

@LiamAjones
Copy link

Bug description:

Adding a ngbtooltip to the first focus-able element will result in an error when the modal is opened.

Error thrown is

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'className: undefined'. Current value: 'className: tooltip show'. It seems like the view has been created after its parent and its children have been dirty checked. Has it been created in a change detection hook ?

Link to minimally-working StackBlitz that reproduces the issue:

Link to stack blitz

Versions of Angular, ng-bootstrap and Bootstrap:

Angular:
7.0.0
ng-bootstrap:
4.1.1

@maxokorokov
Copy link
Member

Looks like broken since recently:

  • autofocus in modal window happens in the afterViewInit lifecycle hook and is done synchronously.
  • we started opening tooltip on focus by default in 4.1.0, so focusing triggers tooltip opening
  • on tooltip open there is only markForCheck() and by this time has CD already run on the tooltip.

Proposal is to do two things:

  • I guess we should force-run change detection in tooltip on open, because we never know from where it will be opened
  • We should focus modal by setting timeout when the zone is stable (least priority possible I suppose)
this._zone.onStable.asObsevable().pipe(take(1)).subscribe(() => setTimeout(() => {
  // call element.focus(); here
}, 0))

@benouat
Copy link
Member

benouat commented Apr 30, 2019

I guess we should force-run change detection in tooltip on open, because we never know from where it will be opened

That one should be fixed when #3138 land

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants