Skip to content

Modal: fix dispose function #38857

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions js/src/modal.js
Copy link
Member

@GeoSot GeoSot Jul 6, 2023

Choose a reason for hiding this comment

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

It would be great to add a test too, supporting your solution

NOTE for reviewers:
The proposed change is valid.
My only consideration is, whether we should handle such situations or not. In case we decide to handle them, we should also think about the other components too

Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ class Modal extends BaseComponent {
}

dispose() {
EventHandler.off(window, EVENT_KEY)
EventHandler.off(this._dialog, EVENT_KEY)
this._element.addEventListener(EVENT_HIDDEN, () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
this._element.addEventListener(EVENT_HIDDEN, () => {
EventHandler.on(this._element, EVENT_HIDDEN, () => {

try this syntax to be aligned with the rest codebase ;wink

EventHandler.off(window, EVENT_KEY)
EventHandler.off(this._dialog, EVENT_KEY)

this._backdrop.dispose()
this._focustrap.deactivate()
this._backdrop.dispose()
this._focustrap.deactivate()

super.dispose()
})

super.dispose()
this._hideModal()
}

handleUpdate() {
Expand Down