material-ui-currency-textfield icon indicating copy to clipboard operation
material-ui-currency-textfield copied to clipboard

Updated package to use MUI v5

Open alext9586 opened this issue 3 years ago β€’ 18 comments

Updated packages and imports so that it can be used with the newest version of Material UI. Also removed withStyles in favor of using style attribute for text align as per MUI v5 upgrade.

alext9586 avatar Jan 12 '22 23:01 alext9586

I've a question: why do u use "style" instead of sx?

GhostyJade avatar Jan 13 '22 11:01 GhostyJade

Good question! The textAlign has to be attributed to the base input element via style to actually align the text within the input field. The base input DOM element doesn't know what sx does because it's not a w3 attribute. The sx attribute is a MUI concept and only works on the MUI high order component (ie- TextField and Input with a capital I) and I've tried it on both MUI components, but it does not appear to propagate down to the actual input (with a lowercase i) element so the text never aligns with sx.

alext9586 avatar Jan 13 '22 17:01 alext9586

I think that's wierd since sx is recognized by the TextField component. To target the input component directly you should target the MUI's css class, something like:

     sx={{
          "& .MuiInput-input": {
            textAlign: this.props.textAlign || "right",
          },
     }}

Also, if u can, can u migrate the example directory to use mui5? Thanks c:

GhostyJade avatar Jan 14 '22 08:01 GhostyJade

Ah, I was just thowing textAlign in the sx attribute instead of using the class name. That's why it wasn't working. I've committed the change and updated the example project.

alext9586 avatar Jan 14 '22 18:01 alext9586

Thanks! And now we wait for the merge approval

GhostyJade avatar Jan 15 '22 17:01 GhostyJade

Is there anything I can do to help get this merged?

philliphuang avatar Feb 15 '22 23:02 philliphuang

I don't think there's anything we can do other than bother @merlos or @sureshsevarthi to review and merge the changes

alext9586 avatar Feb 16 '22 00:02 alext9586

@merlos @sureshsevarthi please πŸ₯ΊπŸ™

philliphuang avatar Feb 25 '22 18:02 philliphuang

please I'm waiting for it too. πŸ™πŸ»

sciotta avatar Feb 26 '22 02:02 sciotta

I neeeeeed this !!

ajoslin103 avatar Mar 10 '22 04:03 ajoslin103

Any help needed to merge this issue? MUI v5 really needs it, and looks like a simple merge.

rHilkner avatar Apr 14 '22 22:04 rHilkner

This PR is 8 months old, and would allow me to leverage this package in my project. Anything the community can do to help get this merged?

anied avatar Aug 10 '22 18:08 anied

can i use your version? @alext9586

GuilhermeGuiuler avatar Sep 13 '22 14:09 GuilhermeGuiuler

@GuilhermeGuiuler Yes, absolutely, go for it

alext9586 avatar Sep 13 '22 16:09 alext9586

@alext9586 how could i install this version in my project?

GuilhermeGuiuler avatar Sep 13 '22 17:09 GuilhermeGuiuler

@GuilhermeGuiuler In my fork, go to src/components/CurrencyTextField/CurrencyTextField.js and copy that file into the components folder of your project and use it like any component. Then import any of the missing dependencies from NPM (I believe "autonumeric" is the only one you'd need).

alext9586 avatar Sep 13 '22 19:09 alext9586

Hi @alext9586 unfortunately this does not seem to work with the latest versions of MaterialUI. I have the following dependencies:

    "@emotion/react": "^11.11.1",
    "@emotion/styled": "^11.11.0",
    "@mui/material": "^5.14.10",
    "autonumeric": "^4.10.0",
    "react": "18.2.0",
    "tss-react": "^4.9.2",

And when adding the modified CurrencyTextField to my components folder i get the following error when using it:

TypeError: Cannot read properties of undefined (reading 'muiName')

It only occurs when adding the CurrencyTextField component so it must be something in the component but i can't seem to figure it out. Would you like to take a look at it?

Note; modifying the inputs from this:

import { TextField, InputAdornment } from "@mui/material"

to this:

import TextField from "@mui/material/TextField" import InputAdornment from "@mui/material/InputAdornment"

did not help.

gvdhoven avatar Sep 26 '23 11:09 gvdhoven

@gvdhoven Sorry I can't help with this issue. I'm not sure what would have changed in the latest version of MUI, but I know it's still working with MUI v5.13.5 in my project.

alext9586 avatar Sep 26 '23 16:09 alext9586