-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Submit/Reset inputs lose text when value=undefined. #12872
Comments
IMHO, this should be done outside of React, like: <input type="submit" value={someVal ? someVal : 'whatever'} /> But let's also listen to other people's opinion. 😄 |
Possibly. I'm hoping to be able to rely on the browser's default text so that I don't have to worry about creating localised text for the button itself. |
Actually on second thought though, if you have this in your bare html: <input type="submit" value> It would also show up this button with no text on it as well. Consistent-wise, I think this should not be a case where React bothers to do extraneous work to give it a default value. |
Ah, but remember that a bare attribute does not mean In other words, setting |
Or, another way of expressing what I just said: JSX <div className={undefined}>Hello, world</div> Computes to the following HTML: <div>Hello, world</div> I believe the behaviour should be the same for the situation I've described in this issue. |
We recommend using |
Do we know when this regressed? |
Is the fix here to simply bail-early on ReactDOMInput behavior from applying to submit/reset inputs? I wonder what would happen if you switched from |
Do you want to request a feature or report a bug?
Bug.
What is the current behavior?
Creating an
<input type='submit'
withvalue={undefined}
results in a button with no text. https://codesandbox.io/s/nn7p94y3rlThe same behaviour can be seen with
type='reset'
I have a PR open with a proposed fix. #12780
What is the expected behavior?
The input should use the browser's default value for the input (Submit for en, etc.).
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 16.3.2. Chrome 66.0.3359.139. macOS 10.13.4. Works in React 15 (unsure of earlier versions)
The text was updated successfully, but these errors were encountered: