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

Fixed Number Type Textfied error #44963 #44967

Closed
wants to merge 3 commits into from

Conversation

yashdev16
Copy link
Contributor

Closes #44963

Description:

This PR fixes an issue where the number input spinner continues to increment even after releasing the mouse button when it was held down. The fix adds a cleanup mechanism that stops the increment operation when the mouse is released.

Solution:

  • Added a numberInputRef to track the specific TextField's number input element
  • Implemented a useEffect hook that handles mouseup events for number inputs
  • Added logic to blur the input when mouse is released, stopping any ongoing increment operations
  • Used mergeRefs to maintain compatibility with external refs while adding our internal ref

Testing:

Manual testing steps performed:

  1. Click and hold the increment button on a number input
  2. Release the mouse button anywhere on the screen
  3. Verify that the number stops incrementing immediately upon release
  4. Verify that other input types and components are not affected

Additional Notes:

  • The fix is specifically targeted to number inputs only
  • Only affects the active TextField's input element
  • Properly cleans up event listeners on unmount
  • Maintains existing ref functionality through proper ref merging

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)

@mui-bot
Copy link

mui-bot commented Jan 7, 2025

Netlify deploy preview

https://deploy-preview-44967--material-ui.netlify.app/

TextField: parsed: +0.24% , gzip: +0.22%
@material-ui/core: parsed: +0.06% , gzip: +0.07%

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against d27d34a

@ZeeshanTamboli
Copy link
Member

@yashdev16 Let's wait for a reproduction before creating a PR. See #44963 (comment). If you are seeing the issue, please share a reproduction first.

@ZeeshanTamboli ZeeshanTamboli added component: text field This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information labels Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: text field This is the name of the generic UI component, not the React module! status: waiting for author Issue with insufficient information
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Number Type Textfied error
3 participants