Giter Club home page Giter Club logo

Comments (16)

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

@evgeniyworkbel The CodeSandbox link you provided is private. Can you make it public?

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

@ZeeshanTamboli I had made

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

@evgeniyworkbel It is because the TextField component isn't re-rendering when the value is cleared through ref because direct manipulation via ref doesn't trigger a re-render in React. You can manually control the shrink state instead: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. However, it would be better to convert your component to a controlled TextField component to handle value clearing more effectively.

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

@evgeniyworkbel It is because the TextField component isn't re-rendering when the value is cleared through ref because direct manipulation via ref doesn't trigger a re-render in React. You can manually control the shrink state instead: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. However, it would be better to convert your component to a controlled TextField component to handle value clearing more effectively.

The CodeSandbox link you provided is private. Can you make it public?

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

@evgeniyworkbel It is because the TextField component isn't re-rendering when the value is cleared through ref because direct manipulation via ref doesn't trigger a re-render in React. You can manually control the shrink state instead: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. However, it would be better to convert your component to a controlled TextField component to handle value clearing more effectively.

The CodeSandbox link you provided is private. Can you make it public?

Made it public now.

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

The behaviour in example is weird

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

The behaviour in example is weird

What is weird?

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

Because I need to debounce value inside to update search params

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

Because I need to debounce value inside to update search params

And you can't do that with a controlled component? Can you show an example? Does the updated CodeSandbox work for you?

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

Because I need to debounce value inside to update search params

And you can't do that with a controlled component? Can you show an example? Does the updated CodeSandbox work for you?

https://codesandbox.io/p/sandbox/cranky-moon-forked-s55hpw?file=%2Fsrc%2FApp.tsx%3A17%2C36

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

Because I need to debounce value inside to update search params

And you can't do that with a controlled component? Can you show an example? Does the updated CodeSandbox work for you?

https://codesandbox.io/p/sandbox/cranky-moon-forked-s55hpw?file=%2Fsrc%2FApp.tsx%3A17%2C36

You are debouncing the function wrong. debounce from @mui/material returns a callback. See the updated CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-fn2x9x?file=%2Fsrc%2FControlledInput.tsx%3A18%2C17. Also make sure to clear the callback after unmounting with debouncedOnChange.clear().

from material-ui.

evgeniyworkbel avatar evgeniyworkbel commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

Because I need to debounce value inside to update search params

And you can't do that with a controlled component? Can you show an example? Does the updated CodeSandbox work for you?

https://codesandbox.io/p/sandbox/cranky-moon-forked-s55hpw?file=%2Fsrc%2FApp.tsx%3A17%2C36

You are debouncing the function wrong. debounce from @mui/material returns a callback. See the updated CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-fn2x9x?file=%2Fsrc%2FControlledInput.tsx%3A18%2C17. Also make sure to clear the callback after unmounting with debouncedOnChange.clear().

it makes sense but the problem remains: controlled input is debounced badly - user wants to type fast and controlled input don't allow this

from material-ui.

ZeeshanTamboli avatar ZeeshanTamboli commented on September 1, 2024

The behaviour in example is weird

What is weird?

Label is not shrinked when is typing

I updated the CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-8wkr3q. As asked before, why don't you convert your component to controlled component to handle such cases seamlessly.

Because I need to debounce value inside to update search params

And you can't do that with a controlled component? Can you show an example? Does the updated CodeSandbox work for you?

https://codesandbox.io/p/sandbox/cranky-moon-forked-s55hpw?file=%2Fsrc%2FApp.tsx%3A17%2C36

You are debouncing the function wrong. debounce from @mui/material returns a callback. See the updated CodeSandbox: https://codesandbox.io/p/sandbox/cranky-moon-forked-fn2x9x?file=%2Fsrc%2FControlledInput.tsx%3A18%2C17. Also make sure to clear the callback after unmounting with debouncedOnChange.clear().

it makes sense but the problem remains: controlled input is debounced badly - user wants to type fast and controlled input don't allow this

You can sync the value with local state: https://codesandbox.io/p/sandbox/cranky-moon-forked-fn2x9x?file=%2Fsrc%2FControlledInput.tsx%3A15%2C31. I suggest asking such questions on StackOverflow.

from material-ui.

github-actions avatar github-actions commented on September 1, 2024

Since the issue is missing key information and has been inactive for 7 days, it has been automatically closed. If you wish to see the issue reopened, please provide the missing information.

from material-ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.