Skip to content

Conversation

@jackofdiamond5
Copy link
Member

Closes #7697

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them

@jackofdiamond5 jackofdiamond5 requested a review from wnvko July 14, 2020 14:15
@jackofdiamond5 jackofdiamond5 force-pushed the bpenkov/consecutively-close-overlays-on-esc branch from 5a024a9 to b78303d Compare July 14, 2020 15:54
wnvko
wnvko previously approved these changes Jul 15, 2020
@wnvko wnvko requested a review from damyanpetev July 15, 2020 08:26
@valadzhov valadzhov added 💥 status: in-test PRs currently being tested and removed ❌ status: awaiting-test PRs awaiting manual verification labels Jul 15, 2020
Copy link
Member

@damyanpetev damyanpetev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure on the names of the options - looking at the rest of OverlaySettings options, the shortened closeOnEsc doesn't fit too nicely. Also the dialog option might be a bit too explicit/long - perhaps a consistent closeOnEscape for both can be better?

// if all overlays minus closing overlays equals one add the handler
if (this._overlayInfos.length - this._overlayInfos.filter(x => x.closeAnimationPlayer
&& x.closeAnimationPlayer.hasStarted()).length === 1) {
fromEvent(this._document, 'keydown').pipe(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so once this subscription is active, there's no mechanism to remove it (outside of destroy, which is basically never for a root service)? I don't like a key handler to be permanently active TBH. Also the check is all wrong - length alone doesn't tell you much, where's the closeOnEsc before setting the listener? And won't this keep adding subscriptions if just one overlay is shown at a time (length === 1)?

Don't get me wrong, the old version with subscribing to the wrapper is also no good as it never unsubscribed and rxjs won't do that for removed elements either. If you want to use the event observable - do store subscription, check closeOnEsc before even setting it up and use similar logic to unsubscribe like outside click.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsubscribing is fixed now.
This will never subscribe more than once. When calling show for the first overlay it will subscribe. Then if you close this overlay and during its close animation open a new one two things will happen. First in hide call subscription will be removed. Then in show there will be still two overlays active, and one with closing animation playing - it will subscribe which is correct.

@wnvko wnvko requested review from damyanpetev and wnvko July 16, 2020 12:17
wnvko
wnvko previously approved these changes Jul 16, 2020
@wnvko wnvko force-pushed the bpenkov/consecutively-close-overlays-on-esc branch from de83d40 to 19beb73 Compare July 16, 2020 13:22
@wnvko wnvko force-pushed the bpenkov/consecutively-close-overlays-on-esc branch from 19beb73 to 8547d90 Compare July 16, 2020 13:55
damyanpetev
damyanpetev previously approved these changes Jul 16, 2020
Copy link
Member

@damyanpetev damyanpetev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on extra check when removing handler, otherwise LGTM

this._overlayInfos
.filter(o => o.closeAnimationPlayer && o.closeAnimationPlayer.hasStarted())
.length;
if (this._overlayInfos.length - closingOverlaysCount === 1 && this._keyPressEventListener && !this._keyPressEventListener.closed) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think the closed check does much if you are de-ref the subscription property anyway. Is there a way for it to be still assigned yet be closed?

@Lipata Lipata requested a review from damyanpetev July 17, 2020 06:20
@valadzhov valadzhov added ✅ status: verified Applies to PRs that have passed manual verification and removed 💥 status: in-test PRs currently being tested labels Jul 17, 2020
@valadzhov
Copy link
Collaborator

Verified that the PR is working but logged #7803 related to the overlay not closing while another overlay's closing animation is in progress.

@Lipata Lipata merged commit 4d2ca73 into master Jul 17, 2020
@Lipata Lipata deleted the bpenkov/consecutively-close-overlays-on-esc branch July 17, 2020 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

overlay version: 10.1.x ✅ status: verified Applies to PRs that have passed manual verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not close modal overlay on ESC key press

6 participants