Skip to content
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

useTextField et al. create empty value attribute #3708

Closed
brandonpittman opened this issue Nov 3, 2022 · 0 comments
Closed

useTextField et al. create empty value attribute #3708

brandonpittman opened this issue Nov 3, 2022 · 0 comments

Comments

@brandonpittman
Copy link
Contributor

brandonpittman commented Nov 3, 2022

🐛 Bug Report

In the same vein as #3554, the useTextField hook passes along undefined as the value for value when a value isn't supplied. This causes trouble when submitting forms as GET requests (especially) because it creates searchParam soup in the URL.

🤔 Expected Behavior

  1. If no value is passed to an input, no value attribute should exist in the DOM.
  2. An empty input shouldn't change the searchParams when submitting a GET request in a form

😯 Current Behavior

  1. All inputs created using useTextField have value attributes in the DOM, even when they aren't passed one.
  2. Empty inputs add searchParams to the URL like ?emptyInputName=

💁 Possible Solution

Fix is using the same method as checkboxes were recently fixed.

#3554

🔦 Context

I'm trying to create a search filter and the all inputs are submitting empty strings—creating entries for each in the searchParams.

💻 Code Sample

https://codesandbox.io/s/naughty-fast-jg5wp3?file=/src/App.js

If you remove the inputProps from the input, the unnecessary value attribute goes away.

🌍 Your Environment

Software Version(s)
react-aria. 3.20
Browser Chrome 106
Operating System macOS 12.6

🧢 Your Company/Team

Splink Inc.

@brandonpittman brandonpittman changed the title useTextField et al. create empty attribute useTextField et al. create empty value attribute Nov 3, 2022
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

No branches or pull requests

1 participant