fix: prevent selecting duplicate files in the same modal session - #2748
Open
andrewleith wants to merge 7 commits into
Open
fix: prevent selecting duplicate files in the same modal session#2748andrewleith wants to merge 7 commits into
andrewleith wants to merge 7 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the attachments UI by blocking users from selecting the same file more than once during a single “Attach files” modal session, and adds a regression test to ensure duplicates are detected and reported.
Changes:
- Add in-modal duplicate detection (against already-selected pending files) and filter duplicates out of the accepted selection.
- Deduplicate reported validation issues before surfacing them to the parent via
onIssuesChange. - Add a Jest test covering duplicate selection within the same modal session.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/assets/javascripts/attachments/AttachFilesModal.js | Filters newly selected files to prevent duplicates against the modal’s existing pending selection and reports a duplicate issue. |
| tests/javascripts/attachments/AttachFilesModal.test.js | Adds a test verifying duplicate selection triggers an issue and does not add a second pending item. |
Comments suppressed due to low confidence (1)
app/assets/javascripts/attachments/AttachFilesModal.js:177
- After handling a file selection, the file input should be cleared (set to an empty string) so choosing the same file again reliably fires a change event across browsers. Without this, the duplicate-selection validation may not run if the user re-selects the same file.
const normalizedFiles = filteredAcceptedFiles.map((file) => ({
id: `${file.name}-${file.size}-${file.lastModified || 0}-${Math.random()}`,
file,
}));
setSelectedFiles((currentFiles) => [...currentFiles, ...normalizedFiles]);
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
🧪 Review environmenthttps://44vmum6g6cpewj3nikpwvwjvhi0kpfhz.lambda-url.ca-central-1.on.aws/ |
…ed for valid files
andrewleith
marked this pull request as ready for review
July 28, 2026 13:03
jzbahrai
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 | Résumé
This pull request improves the file attachment modal by preventing users from selecting the same file more than once in a single session. It also adds a test to verify that duplicate files are detected and reported as issues.
Test instructions | Instructions pour tester la modification
Prevents duplicates between reloads
Prevents duplicates done one at a time
Prevents duplicates done at the same time