Fix Modal destructor when modal is removed while open #2962
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
π Summary
Fix destructor when
<dialog>
is open and the component is destroyed.π οΈ Detailed description
Pre 4.19, the page overflow property was always reset after the
<dialog>
was closed.In a recent refactor intended as a fix the overflow property was reset only when the
<dialog>
was closed.There are instances across products where the Modal component is destroyed without being properly closed. By properly closed I mean using the
close
function (via the close button on the top right corner of the dialog, or via a footer button bound to this action), clicking outside of the dialog or pressing the escape key. When this happens the page overflow is not reset.To avoid such instances I suggest we emulate the
close()
event if the<dialog>
is removed from the DOM while open, so it behaves similar to close action.Borrowed the showcase example from #2961 and added a test to cover this scenario.
π External links
Jira ticket: HDS-4975
π Component checklist
π¬ Please consider using conventional comments when reviewing this PR.
π PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.