-
Notifications
You must be signed in to change notification settings - Fork 8
fix(NxModal): prevent modal closure on file input cancel events #1233
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
Conversation
React 18 Spike - RSC-1550
…nChange_signature Update NxFormSelect onChange signature- RSC-1719
Co-authored-by: Ross Pokorny <rpokorny@sonatype.com>
…me_for_NxCollapsibleItemsSelect Support JSX option name for NxCollapsibleItemsSelect - RSC-1283
RSC 13.0.0 React 18 - RSC-1550 Update NxFormSelect onChange signature - RSC-1719 Support JSX option name for NxCollapsibleItemsSelect - RSC-1283
Update visualtest instructions with new docker container
Fix error button colors - RSC-1796
Upgrade all potentially-relevant packages for CVE-2025-55182
- Add event.target check in cancel event handler - Prevents modal from closing when file input cancel events bubble up - Only handle cancel events originating from the dialog itself
|
Consider this optional since you're new, but ideally there would be a functional test (in the visual-tests suite) that validates this fix. This would require an example of a modal which contains a file upload to be added to the gallery as well, as that would be what the test operates on. Also, note that the build for this repo requires that you bump the version numbers in the package.json files before the build will pass, this is so that when it merges to |
|
I notice that this branch was unfortunately based off of, and is being merged into, the wrong target branch. Since the goal here is the fix an issue seen in IQ, and IQ is still on RSC 12, you need to re-create this branch off of the After the PR is complete and merged to |
|
Closing this PR as it was targeting the wrong base branch ( Since IQ uses RSC 12.x, the fix needs to be merged into New PR created: [link to your new PR] |
Problem
NxModalregisters a cancel event handler that fails to distinguish between cancel events from the dialog itself versus those from descendant elements. File input elements (<input type="file">) also fire cancel events when users cancel file selection or select the same file again, causing the modal to close unexpectedly.This affects any modal containing file inputs, such as the SBOM Import Modal.
Root Cause
The
AbstractDialog.tsxcomponent's cancel event listener was directly callingonCancelfor all cancel events without checking the event source. Cancel events bubble up from child elements, triggering the modal to close when it shouldn't.Solution
Added event target validation in the cancel event handler to filter events:
event.target === dialogChanges Made
Modified
lib/components/NxModal/AbstractDialog.tsx:event.target === dialogcheck before callingonCanceladdEventListenerandremoveEventListenerto use the wrapper functionTesting
Tested scenarios:
Steps to Test:
Jira
Jira ticket(s) link: https://sonatype.atlassian.net/browse/CLM-36834
PR Checklist
12.x-backportsbranch