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

Add support for the name attribute in the Input component #2467

Open
MrLapa opened this issue Sep 16, 2024 · 3 comments
Open

Add support for the name attribute in the Input component #2467

MrLapa opened this issue Sep 16, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle

Comments

@MrLapa
Copy link

MrLapa commented Sep 16, 2024

Description

Currently, the Input component in Gluestack UI does not support the name attribute, which is essential for handling form submissions and integration with form libraries like react-hook-form. Adding support for the name attribute would make it easier to manage forms and improve the flexibility of the component in various use cases.

Problem Statement

The lack of a name attribute in the Input component presents a limitation when using it with form libraries such as react-hook-form. The name attribute is necessary for proper form field management, especially when dealing with controlled components in complex forms. Without this attribute, it's challenging to integrate the Input component into form handling processes, potentially leading to a more cumbersome development experience.

Proposed Solution or API

Add support for the name attribute to the Input component in Gluestack UI. The component should accept a name prop and pass it down to the underlying input element, making it compatible with form libraries. Here is a code snippet illustrating the proposed change:

<Input
  name={name} // Add this line to support the name attribute
  inputAccessoryViewID="close"
  onBlur={(event: any) => {
    field.onBlur();
    props.onBlur?.(event);
  }}
  onChangeText={(text: any) => {
    const normalizedText = normalize ? normalize(text) : text;
    field.onChange(normalizedText);
    props.onChangeText?.(normalizedText);
  }}
  ref={(input) => {
    if (inputRef) {
      setRef(inputRef, input);
    }
    setRef(field.ref, input);
  }}
  testID={`InputField[${name}]--Input`}
  value={format?.(field.value) ?? field.value}
  {...props}
/>

In this example, the name prop is added to the Input component, which allows it to be utilized in form submissions and other form-handling mechanisms.

Alternatives

No response

Additional Information

No response

@Viraj-10 Viraj-10 added enhancement New feature or request gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle labels Sep 17, 2024
@MrLapa
Copy link
Author

MrLapa commented Sep 20, 2024

Hi @Viraj-10, I wanted to follow up on this issue. Do you think this could be addressed in a future version? Thank you!

@Viraj-10
Copy link
Collaborator

Hey @MrLapa, Yes, we will address this in future.

@Viraj-10
Copy link
Collaborator

@MrLapa If you can implement and send PR that would be great as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gluestack-ui-unstyle Issue is due to gluestack-ui-unstyle
Projects
Status: Backlog
Development

No branches or pull requests

2 participants