2 Replies Latest reply on Jan 23, 2008 4:19 PM by dan1123

    TextArea - Incorrect textHeight after backspace

    dan1123 Level 1

      There seems to be a bug in the TextArea control, where backspacing a line break doesn't trigger a change event. I can work around that by detecting the backspace keypress directly and firing my own event, but then when I check the textHeight of the textArea, it gives me the height as if the line were still there.

      The next time the change event fires (ie the user presses another key), the control sets the textHeight to the correct value. I've tried using revalidating the textArea on the backspace key press, but it doesn't seem to make any difference. I've tested on both a Mac and a PC.

      Is this a know bug or am I just missing something here? Does anyone have a good workaround?

        • 1. Re: TextArea - Incorrect textHeight after backspace
          Rahil Kidwai
          I was having the same problem while checking for text overflow in the text area. I was generating a custom event for text overflow in text area by comparing textheight and control height.

          A good workaround i think is to use "callLater()" method.
          You need to do the following:
          - Put all your code related to height processing in a separate method. for eg HeightProcessing(arguments_if_any)
          - Capture the change event of text area
          - Inside change event handler, call the method
          callLater(HeightProcessing, argument_values_if_any)

          Hope it will solve your problem.

          Just capture Change event
          • 2. Re: TextArea - Incorrect textHeight after backspace
            dan1123 Level 1
            Thanks Rahil!

            I was actually fiddling with this today and came up with another workaround, but I think I like yours better since it doesn't require subclassing the TextArea control.

            For the record, if you subclass the TextArea control, then calling this.getTextField().textHeight seems to always give the correct height even when the value returned by this.textHeight is incorrect.