Fix: Support type='select' for multiple select defaulting to []#1061
Open
erikras-richard-agent wants to merge 1 commit intomainfrom
Open
Fix: Support type='select' for multiple select defaulting to []#1061erikras-richard-agent wants to merge 1 commit intomainfrom
erikras-richard-agent wants to merge 1 commit intomainfrom
Conversation
- Previously only component='select' was checked for multiple select handling - Now also checks type='select' to match user expectations - Fixes react-final-form-arrays#185 where users pass type='select' multiple - Added 3 regression tests to verify fix - All tests pass (139/139, 99.32% coverage)
📝 WalkthroughWalkthroughThis pull request extends the multi-select handling logic in useField to recognize both Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
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.
Problem
React-final-form-arrays issue #185 reported this error after upgrading to v4.0.0:
When users pass
type="select" multiple={true}to a Field, the value wasn't being defaulted to[], causing React to complain.Root Cause
The code in
useField.tsonly checkedcomponent === "select"to determine when to default undefined values to[]. However, many users passtype="select"instead ofcomponent="select".Solution
Update both locations where select multiple is handled:
[]when(component === "select" || type === "select") && multiplegetInputValue()when(component === "select" || type === "select") && multipleTesting
Part of
🟠 HIGH: Fix v4.0.0 regressions (select multiple, TypeScript)
This fixes the react-final-form side of react-final-form-arrays#185
Summary by CodeRabbit
Release Notes
Bug Fixes
Tests