[TextField] Cursor jumps to beginning when clicking outside the default line-height area
@siriwatknp is already working on this.
Since Nov 14, 2024.
Assessment
This issue has not been assessed yet.
Description
Steps to reproduce
Link to live example: (required)
Go to the TextField demo page on MUI’s website.
Steps:
- Type some text into any TextField component.
- Click above the input area, especially outside the text’s line-height area (e.g., towards the top of the field).
https://github.com/user-attachments/assets/b8534f17-d429-49e1-9c82-951db7292223
3 .Observe the cursor behavior—it should ideally position itself where you clicked but instead jumps to the beginning of the text. Unless you click in the small native input line height.
Current behavior
When using the TextField component, clicking within the input area but outside the default line-height (e.g., in the top half of the input area) causes the cursor to jump to the beginning of the text instead of positioning where the click occurred. This behavior causes the input field to respond in an unexpected and inconsistent way for users.
Expected behavior
The cursor should appear at the exact location where the user clicks within the input area, aligning with standard input field behavior and enhancing user experience.
Context
This issue affects the user experience by causing unexpected cursor jumps within the input area. It occurs even with the default TextField styling, making it a general issue in applications that use MUI’s TextField component.
Your environment
npx @mui/envinfo
System:
OS: macOS 14.6.1
Binaries:
Node: 20.16.0 - /opt/homebrew/opt/node@20/bin/node
npm: 10.8.1 - /opt/homebrew/opt/node@20/bin/npm
pnpm: Not Found
Browsers:
Chrome: 130.0.6723.117
Edge: Not Found
Safari: 17.6
npmPackages:
@emotion/react: ^11.11.3 => 11.11.3
@emotion/styled: ^11.11.0 => 11.11.0
@mui/base: 5.0.0-beta.61
@mui/core-downloads-tracker: 6.1.6
@mui/icons-material: ^6.1.6 => 6.1.6
@mui/lab: ^6.0.0-beta.14 => 6.0.0-beta.14
@mui/material: ^6.1.6 => 6.1.6
@mui/private-theming: 6.1.6
@mui/styled-engine: 6.1.6
@mui/system: ^6.1.6 => 6.1.6
@mui/types: 7.2.19
@mui/utils: 5.15.9
@mui/x-charts: ^6.18.7 => 6.18.7
@mui/x-data-grid: ^6.18.4 => 6.18.6
@types/react: 18.3.12
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
typescript: 4.9.5
Search keywords: TextField cursor placement , TextField line-height issue, TextField cursor misalignment, MUI TextField cursor jump
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mui/material-ui
-
type: new feature waiting for 👍
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mui/material-ui#48254 · 3 comments · 1 reaction ·
-
has workaround scope: avatar waiting for 👍
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
mui/material-ui#48190 · 5 comments ·
-
has workaround scope: typography type: new feature waiting for 👍
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
mui/material-ui#46488 · 2 comments · 1 reaction ·
-
has workaround scope: text field type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mui/material-ui#37216 · 6 comments ·
-
docs scope: autocomplete
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
mui/material-ui#35713 · 5 comments ·
Similar issues
-
code-quality refactoring
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/gh-aw-firewall#8816 ·
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100