-
Notifications
You must be signed in to change notification settings - Fork 31
GAUD-10113 - Handle disconnected dialog more gracefully #7045
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,12 @@ export const DialogMixin = superclass => class extends superclass { | |
| disconnectedCallback() { | ||
| super.disconnectedCallback(); | ||
| window.removeEventListener('d2l-mvc-dialog-open', this._handleMvcDialogOpen); | ||
|
|
||
| // remove handlers, reset state and allow body scrolling if dialog is removed from the DOM before fully closing | ||
| this._removeHandlers(); | ||
| this._state = null; | ||
| this.opened = false; | ||
|
Comment on lines
+113
to
+114
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really sure if these are needed - I can't see a case where you've navigated away and the same component is later somehow re-connected. But maybe in a non-navigation case where a dialog was removed forcefully but later added back?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah idk... it's kinda of a weird case. In theory, someone could remove the dialog from the DOM in the open state, and then reconnect it, and I'd usually expect the component to be in the same state as when it was disconnected. But in practice, I'm not really expecting anyone to do that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Messing with
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... I think that general behaviour of whether to maintain state depends on the property. I can probably think of case that would go either way on that. In this case though, it's probably fine to put the dialog into the closed state when it's disconnected.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think if opened changes, the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the main reason I thought to set |
||
| if (this._useNative) allowBodyScroll(this); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This matches what
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the issue is that the |
||
| } | ||
|
|
||
| async updated(changedProperties) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could arguably just be
window.removeEventListener('resize', this._updateSize);, but I figured it might be better to call the same function as_handleClosein case morewindow-level ones were added somedayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be worth putting what you've added here into something like a
#doCloseCleanup()that gets called from here and_handleClose? Just in case we add more to_handleCloseit'll at least force the conversation about whether that belongs in the central place or not.