question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextArea incorrect height with autoHeight prop when element is not visible

See original GitHub issue

Update Managed to find out exactly why this issue happens. Will come back and edit this with and jsfiddle that replicates exactly this issue. Spoiler, it has to do with setting tabular items.

I am getting this weird issue when using Form.TextArea with autoHeight and disabled props. The height of the textarea is not set correctly as you can see in the SS below:

screen shot 2017-03-01 at 12 13 47 pm

Here is the JSX:

<Grid>
  <Grid.Row columns={2}>
    <Grid.Column>
      <Header size="small">General Conditions</Header>
      <Form.TextArea label="Textarea 1" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
    </Grid.Column>
    <Grid.Column>
      <Header size="small">Special Conditions</Header>
      <Form.TextArea label="&nbsp;" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
    </Grid.Column>
  </Grid.Row>
  <Grid.Row columns={2}>
    <Grid.Column>
      <Form.TextArea label="Textarea 2" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
    </Grid.Column>
    <Grid.Column>
      <Form.TextArea label="&nbsp;" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
    </Grid.Column>
  </Grid.Row>
  <Grid.Row columns={2}>
    <Grid.Column>
      <Form.TextArea label="Textarea 3" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
    </Grid.Column>
    <Grid.Column>
      <Form.TextArea label="&nbsp;" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
    </Grid.Column>
  </Grid.Row>
</Grid>

Under inspect element, the style properties for the TextArea are being set as:

min-height: 0px;
resize: none;
height: 2px;

Where the height: 2px is obviously wrong.

Version

0.67.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
edchioucommented, Mar 23, 2017

Version: 0.67.1

I was able to reproduce the problem with AutoHeight when trying to render a Form.TextArea component inside an Accordion.

import React from 'react'
import { Form, Accordion, Label, Message } from 'semantic-ui-react'
import faker from 'faker'
import _ from 'lodash'

const panels = _.times(3, i => ({
  key: `panel-${i}`,
  title: <Label color='blue' content={faker.lorem.sentence()} />,
  content: (
    <Form>
      <Form.TextArea placeholder='Try adding multiple lines' autoHeight />
    </Form>
  ),
}))

const AccordionExamplePanelsPropWithCustomTitleAndContent = () => (
  <Accordion panels={panels} />
)

export default AccordionExamplePanelsPropWithCustomTitleAndContent

It looks like this: textareainsideaccordion

When I start typing inside the text area, it will immediately resize to the correct height.

1reaction
levithomasoncommented, Mar 2, 2017

Form.TextArea renders a form field with a textarea child. The code provided is missing the Form around the Form.TextArea. Pasting the above example into the doc site and correcting the markup renders:

import React from 'react'
import { Grid, Header, Form } from 'semantic-ui-react'

const TextAreaExampleAutoHeight = () => (
  <Grid>
    <Grid.Row columns={2}>
      <Grid.Column>
        <Header size="small">General Conditions</Header>
        <Form>
          <Form.TextArea label="Textarea 1" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
        </Form>
      </Grid.Column>
      <Grid.Column>
        <Header size="small">Special Conditions</Header>
        <Form>
          <Form.TextArea label="&nbsp;" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
        </Form>
      </Grid.Column>
    </Grid.Row>
    <Grid.Row columns={2}>
      <Grid.Column>
        <Form>
          <Form.TextArea label="Textarea 2" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
        </Form>
      </Grid.Column>
      <Grid.Column>
        <Form>
          <Form.TextArea label="&nbsp;" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
        </Form>
      </Grid.Column>
    </Grid.Row>
    <Grid.Row columns={2}>
      <Grid.Column>
        <Form>
          <Form.TextArea label="Textarea 3" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
        </Form>
      </Grid.Column>
      <Grid.Column>
        <Form>
          <Form.TextArea label="&nbsp;" defaultValue="Lorem Ipsum" disabled readOnly autoHeight />
        </Form>
      </Grid.Column>
    </Grid.Row>
  </Grid>
  )

export default TextAreaExampleAutoHeight

image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Textarea Auto height [duplicate] - javascript - Stack Overflow
This using Pure JavaScript Code. function auto_grow(element) { element.style.height = "5px"; element.style.height = (element.
Read more >
resize - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The resize CSS property sets whether an element is resizable, and if so, ... The element offers no user-controllable method for resizing it....
Read more >
The Cleanest Trick for Autogrowing Textareas
/* easy way to plop the elements on top of each other and have them both sized based on the tallest one's height...
Read more >
Solved: HTML element - auto-resize a <text area> from a Mu...
I was thinking I could change the height property to "height:auto", but it is doing nothing. At the moment this value is set...
Read more >
Make a Textarea Auto Resize to fit Contents - Impressive Webs
A <div> element will naturally stretch to fit the height of its content (assuming no floats or absolutely positioned elements are involved). So ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found