Extendable input div(just like facebook and X create post component) #142643
Replies: 2 comments 1 reply
-
// EditableContainer component const EditableContainer = () => { const handleInput = () => { const adjustHeight = (element) => { useEffect(() => { return ( <div ref={divRef} contentEditable onInput={handleInput} className={ relative p-3 overflow-y-auto w-full rounded-lg focus:outline-none ${content === '' ? 'before:content-[attr(data-placeholder)] before:text-gray-400 before:absolute' : ''} }data-placeholder="What's on your mind today?" > ); }; export default EditableContainer; Parent Component (Where the Slider Is Rendered):
{images.length > 0 && (
)}
|
Beta Was this translation helpful? Give feedback.
-
thanks for all your support. It's been sorted. |
Beta Was this translation helpful? Give feedback.
-
Body
I have a model in next js that enables users to post something, the post could be in the form of plain text or contains images as well, since it's a model so I have to add an overflow to it,
For example:
when we upload images it add an overflow to the parent div, and then we start typing something it actually increase the height of the input result in pushing down the uploaded images, that's I want to achieve
My Problem:
I have the same component, I have a editable div and then below that I am actually displaying the uploaded images using shadcn slider, the problem is when I upload a single image the input area shrinks to 'h-10'
I want the entire div to be scroll able means the input div height should increase as the user types something and hits enter.
**Here is my code **
`
this is the EditableContainer component code
` <div
className="flex flex-col gap-4 w-full max-h-96 min-h-14 flex-1 border overflow-y-auto scrollbar-none transition-all"
Guidelines
Beta Was this translation helpful? Give feedback.
All reactions