Skip to content

feat(fileinput): implement controlled file input with onChange callback#568

Merged
stdavis merged 2 commits intomainfrom
feat/controlled-file-input
Dec 5, 2025
Merged

feat(fileinput): implement controlled file input with onChange callback#568
stdavis merged 2 commits intomainfrom
feat/controlled-file-input

Conversation

@stdavis
Copy link
Copy Markdown
Member

@stdavis stdavis commented Dec 5, 2025

This is to support clearing the FileInput state in WRI advanced search.

Copilot AI review requested due to automatic review settings December 5, 2025 18:24
@stdavis stdavis enabled auto-merge (rebase) December 5, 2025 18:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements controlled component support for the FileInput component, enabling external state management and programmatic clearing of files. This is needed to support clearing the FileInput state in WRI advanced search.

Key changes:

  • Replaced onSelect callback (receiving FileList | null) with onChange callback (receiving File[] | null)
  • Added value and onChange props to support controlled mode while maintaining backward compatibility with uncontrolled mode
  • Simplified file management by removing DataTransfer API complexity
  • Updated ReactHookForm integration to use the new controlled API

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/utah-design-system/src/components/FileInput.tsx Implements controlled/uncontrolled component pattern with value/onChange props, replaces onSelect with onChange callback, simplifies file state management
packages/utah-design-system/src/components/FileInput.stories.tsx Updates ReactHookForm story to use new onChange API, adds Controlled story demonstrating external state management with reset functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 5, 2025

Visit the preview URL for this PR (updated for commit 1451cc4):
Firebase Preview: https://ut-dts-agrc-kitchen-sink-dev--feat-controlled-file-inp-neuf0vvr.web.app
(expires "2025-12-19T18:57:43.787312910Z" )

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 5, 2025

@stdavis I've opened a new pull request, #569, to work on those changes. Once the pull request is ready, I'll request review from you.

#569)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stdavis <1326248+stdavis@users.noreply.github.com>
@stdavis stdavis merged commit 9d8178b into main Dec 5, 2025
7 checks passed
@stdavis stdavis deleted the feat/controlled-file-input branch December 5, 2025 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants