Git Product home page Git Product logo

Comments (3)

supersnager avatar supersnager commented on July 29, 2024 1

Hi @chloe-schoreisz, thank you for your question.

The focus can be set using the focus() method provided by the <MessageInput /> component.

e.g.

const inputRef = useRef();
const [disabled, setDisabled] = useState(false);

const sendMessage = () => {
 setDisabled(true);
 senToWire().then( () => {
  inputRef.current.focus();
  setDisabled(false);
});

<MessageInput ref={inputRef} onSend={sendMessage} disabled={disabled} />

from chat-ui-kit-react.

chloe-schoreisz avatar chloe-schoreisz commented on July 29, 2024

Thanks for the solution ! Would this be considered a common use case ? I wonder if it this behaviour should be native to the component.
What other common use cases for the disable props do you have ?

from chat-ui-kit-react.

supersnager avatar supersnager commented on July 29, 2024

@chloe-schoreisz I'm not sure if it is a common use case.
Why do you want disable the input, when a message is sending? If you do it, the user will not be able to write the next message untill the previous one is sent.

What exactly behavior do you consider native, disabling while sending or refocus after sent?

BTW, sorry I forgot about one property activateAfterChange it's meant for a different use case, but you can try setting it to true to automagically set the focus after sending.

Other common use cases for the disabled prop are for example when you have no active user selected, or when connection to server has not been established. Depending on the application, you may also want to block messages from being sent to the user when they are not connected.

from chat-ui-kit-react.

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.