question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

No way to get ref to root of <Input> in a <TextField>

See original GitHub issue
  • This is a v1.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behaviour

<Input> outputs a <div> root that wraps the accents and the input. It should be possible to attach a ref to this input. And it should be possible to do this from a <TextField />.

Current Behaviour

Input only passes {...other} to the <div>

Context

I needed to attach a Popper based menu to the bottom of a TextField, but I need it to open lined up with the whole <Input>, not the <input> (then it’s inset by the inputAdornment) and not the <FormControl> (then when the menu is above the input it will appear above the label instead of overlapping the label).

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jedwards1211commented, Aug 10, 2018

@dantman have you tried <TextField InputProps={{ref: c => this.inputDiv = findDOMNode(c)}} />? (not sure if it works)

0reactions
oliviertassinaricommented, Aug 11, 2018

@dantman for advanced use cases, I encourage people to break the TextField abstraction. You can use the lower level components.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No way to get ref to root of <Input> in a <TextField> #12471
This is a v1.x issue. I have searched the issues of this repository and believe that this is not a duplicate. Expected Behaviour...
Read more >
Unable to retrieve the input field of material UI using refs in ...
Now, I am trying to retrieve the input field value (TextField) using refs of React. It is always saying undefined. This is my...
Read more >
TextInput - Mantine
Capture string input from user. ... Get input ref. import { useRef } from 'react'; ... <TextInput /> // -> not ok, input...
Read more >
React Forms - W3Schools
Handling forms is about how you handle the data when it changes value or gets submitted. In HTML, form data is usually handled...
Read more >
InputAdornment API - Material UI - MUI
Note: If you are using the TextField component or the FormControl component you do not have to set this manually. The ref is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found