I have successfully implemented a textarea box that expands upon click and retracts when it loses focus.
However, I am facing an issue where if the textbox is already in expanded form, I want it to stay expanded if the user clicks anywhere within the container area (the blue section in the provided snippet).
Below is the CSS code for animating the textarea:
.container {
width: 588px;
background: #E8F5FD;
mix-blend-mode: normal;
opacity: 1.00;
border-radius: 3px;
padding: 10px;
}
textarea {
font-family: "Roboto";
font-style: normal;
font-weight: normal;
width:508px;
height:38px;
font-size: 13px;
line-height: 100%;
opacity: 1.00;
border: 1px solid #C6E7FB;
box-sizing: border-box;
border-radius: 3px;
margin-left: 5px;
transition: all 0.0s ease;
resize: none;
}
textarea:focus {
width: 508px;
height: 82px;
}
<div class = "container">
<textarea> </textarea>
<button
type="button"
className="sendButton"
onClick={this.handleSubmit}>Send</button>
</div>
My question is, how can I ensure that the textbox remains in its expanded form when the user clicks anywhere within the container div? And still retracts as intended if clicked outside of the container?