Skip to content

Commit

Permalink
fix: adjust channel input height
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Oct 25, 2023
1 parent 1eb166e commit d0ba888
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { ComponentStory, ComponentMeta } from '@storybook/react'

import CssBaseline from '@mui/material/CssBaseline'
import { INPUT_STATE } from './InputState.enum'

import { ChannelInputComponent, ChannelInputProps } from './ChannelInput'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export const ChannelInputComponent: React.FC<ChannelInputProps> = ({
setMessage(initialMessage)
const ref = textAreaRef.current
if (!ref) return
if (!initialMessage) return
adjustTextAreaHeight(ref)
}, [channelId])

Expand All @@ -263,7 +264,9 @@ export const ChannelInputComponent: React.FC<ChannelInputProps> = ({
const adjustTextAreaHeight = (el: HTMLTextAreaElement) => {
// Workaround for making textarea's height adapt to the content
el.style.height = ''
el.style.height = el.scrollHeight + 'px'
if (el.scrollHeight > el.clientHeight) {
el.style.height = `${el.scrollHeight}px`
}
}

const caretLineTraversal = (focusLine: Node | null | undefined, anchorLinePosition = 0) => {
Expand Down

0 comments on commit d0ba888

Please sign in to comment.