final-form / final-form/react-final-form

Initial value on select is not synced

Open
#327 1 comment 17 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?

Bug report

### What is the current behavior?

Given a field with a `` input, browsers will pre-select the first option. If initialValues is not provided, this pre-selected value will not be synchronized with final-form's internal state. Since this is not obvious, it quickly leads to bugs. Of course it can be circumvented using `initialValues`, but that's not obvious and a bit tedious (especially with an asynchronous list of options).

### What is the expected behavior?

The first (initial) option of a `` should be automatically picked up by react-final-form and synced with final-form's internal state. At the very least there should be a warning when using `` without providing a value for it through `initialValues`.

### Sandbox Link

https://codesandbox.io/s/8ymv5on2wl

Note that 'red' is not persisted in final-form's state, despite it being initially selected by the browser. The only way to make it work is to first select another option, then select red again.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.