Skip to content

Input focus loss #1

Description

@sengardeep

Problem

The input fields in the Quick Quote section of the TradeForm component lose focus after typing a single character.
This typically occurs when the Input component is being re-created on every render, causing React to treat it as a new component instance every time state updates.

Points: 50

Steps to Reproduce

  1. Open the Quick Quote section inside TradeForm.
  2. Click on any input field (e.g., symbol, quantity, or price).
  3. Type one character.
  4. The input immediately loses focus.
  5. Notice:
    • The input cursor jumps out.
    • The component re-renders and replaces the input element with a new instance.

Expected Behavior

The input field should maintain focus while typing continuously.
To ensure this:

  • Avoid defining the Input component inline inside the TradeForm render function.
  • Move the Input component definition outside the parent render, or
  • Wrap it in React.memo() so it maintains a stable identity across renders.

This ensures React does not unmount/remount the component on every keystroke.

Submission Guidelines

  1. Comment on this issue with your proposed solution approach.
  2. Wait for issue assignment from reviewers.
  3. Create a PR with clear, descriptive commit messages.
  4. Reference this issue in your PR description.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Mediummedium issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions