Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: textarea in ion-item collapses when list scrolled #1934

Closed
zapatek opened this issue Aug 5, 2014 · 7 comments
Closed

bug: textarea in ion-item collapses when list scrolled #1934

zapatek opened this issue Aug 5, 2014 · 7 comments
Assignees
Milestone

Comments

@zapatek
Copy link

zapatek commented Aug 5, 2014

Type: bug

Platform: android 4.4 webview

When there is a textarea (higher than single row) in an ion-item within an ion-list, and if the textarea has focus (keyboard showing) and the ion-list is scrolled, then the textarea collapses into a single row while scrolling is on and the bar is visible. The moment the scrolling stops (scroll bar fades) the text area is enlarged to its actual height again.

As an additional problem, when the textarea is large and by itself not scrollable (overflow:hidden) and has focus, then the ion-list also cannot be scrolled by dragging within the textarea either. The list has to be dragged by tapping some place outside the textarea. But if the textarea is very large covering the whole screen, then this becomes a big limitation when trying to edit portions of the textarea that fall outside the screen.

@mhartington mhartington self-assigned this Aug 5, 2014
@mhartington
Copy link
Member

Hey any chance you can put together a codepen or plunker for this and test it against the nightly builds?

@zapatek
Copy link
Author

zapatek commented Aug 6, 2014

Hi Mike, Here is the codepen:

http://codepen.io/zapatek/pen/LmAFf

@mhartington
Copy link
Member

Ah alright, I see what you mean. Going to pass this to @perrygovier for further investigation

@samal-rasmussen
Copy link

I'm having this issue too on beta 11, only outside of an ion-list.

I can see that an extra textarea with class "cloned-text-input" is being added, as is explained here: http://forum.ionicframework.com/t/textarea-and-input-display-problems/4161/13

But I can see that this clone isn't given the same classes or style as the original, and so just has default height.

@samal-rasmussen
Copy link

Found out that putting the textarea inside a label element and giving the textarea it's height via a class, makes the height stay while scrolling. Don't use the rows attribute.

This might just be a case of intended behavior and missing or unclear documentation.

@dargonar
Copy link

dargonar commented Jan 7, 2015

@samal84 solution works for me.

@scmsystm
Copy link

Can we use focusInput.cloneNode() at js/utils/tap.js:191 rather than create new element then clone focused input style?

In my case, if textarea height was set in css then modified by javascript, the cloned textarea height are not equal to newly modified height. (an auto-growing textarea that height modified by scrollHeight itself).

I modify the js/utils/tap.js:184 cloneFocusedInput function like this and the cloned input just fine.
But, I don't really know about the performance.

  cloneFocusedInput: function(container, scrollIntance) {
    if (ionic.tap.hasCheckedClone) return;
    ionic.tap.hasCheckedClone = true;

    ionic.requestAnimationFrame(function() {
      var focusInput = container.querySelector(':focus');
      if (ionic.tap.isTextInput(focusInput)) {
        var clonedInput = focusInput.cloneNode(true);
        if (clonedInput) {
          clonedInput.value = focusInput.value;
          clonedInput.classList.add('cloned-text-input');
          clonedInput.readOnly = true;
          if (focusInput.isContentEditable) {
            clonedInput.contentEditable = focusInput.contentEditable;
            clonedInput.innerHTML = focusInput.innerHTML;
          }
          focusInput.parentElement.insertBefore(clonedInput, focusInput);          
          focusInput.classList.add('previous-input-focus');

          clonedInput.scrollTop = focusInput.scrollTop;
        }
      }
    });
  }

@adamdbradley adamdbradley added this to the 1.0.0-rc0 milestone Feb 10, 2015
@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants