-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
TextField doesn't support 'ref' ? #2699
Comments
I'm working on this as well. The problem is that the ref is passed down to the input. something that doesn't work with React. I'm addressing this in the following PR I'll make. |
OK great, let me know if i can help! when do you expect the PR to land? |
In 20 minute at most. |
i'm not sure if your PR will address this, but in trying to workaround,
with so we can't read via ref, or by using the component methods. Is there another workaround to use these text fields for forms, or one event that does send the fields data along? |
It does get passed into that callback, via the first argument |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
So the solution for being able to use a ref in the |
@schuchowsky: this issue is from December 30th, this is working since a long time ago, man. |
I'm trying to use a ref on a TextField, to attach an |
@schuchowsky: yes, 2 apps running in production and using a few ref props here and there. I strongly suggest using https://github.com/mbrookes/formsy-material-ui though, it's an awesome formsy-react wrapper to match Material UI style. If you are indeed having an issue with |
@schuchowsky check this, this way it works for me. |
Not working in 1.0 |
@TeodorKolev It looks like they have an "inputRef" prop in the new textfield https://material-ui.com/api/text-field/ |
What worked for me, in this case and others using Material UI components, was to wrap a regular component (i.e. div or span) around my Material UI component. Getting the wrapper reference:
Using it:
Code extracted from my open source CMS for Hugo sites. |
Wrap your component using RootRef https://material-ui.com/api/root-ref/ |
@jankalfus: How is RootRef supposed to work? It seems to be incompatible with the default React-
where
To be compatible to the react-ref-hook-standard,
|
@mwaeckerlin |
I found a solution that is compatible with the normal html elements: |
BTW, @jankalfus, I was looking for hours for a tutorial or example on how to use That means, I was not successful in finding a good comprehensive documentation on how to use What I really want, is to use I suggest to make this the default behaviour (so that no explicit |
BTW: I'll use it in conjunction with an addition to Drizzle-React-Components that I am working on. |
In case anyone comes across this looking for answer like I did, take a look at the recent TextField API documentation (https://material-ui.com/api/text-field/#textfield-api). It has an
|
I'm defining a TextField component (within a card) which I pass a ref
but the ref isn't defined ...
How are people making forms with material-ui? Just using the onChange events on every part of the form?
FWIW the TextField is inside a Card/Form
the ref on the wrapper div works fine.
like the very second issue in this repo...
#2
The text was updated successfully, but these errors were encountered: