Scroll issue when dynamically adding element & focusing into it


#1

I’m trying to create a little note-taking app. I want to have a list of contenteditable divs and when the user presses the enter key, I dynamically append a new item onto end of list and focus into it.

I’m having some scrolling problems though so I created a cut-down repro here: http://codepen.io/emertechie/pen/GnxvA

If you click the Add button to add a few items, you’ll notice that you can’t scroll to top of the list anymore. The first ~10 items or so aren’t reachable for me.

The issue seems to be with focusing into new items. If you comment out the el[0].focus() line, things behave ok.

It also happens with a regular text input, so it’s not anything related to contenteditable div.

Any suggestions? Is this a bug?


#2

Hmm, posted too soon it seems. Can’t repro this issue when running the actual app, so this may be something that only appears in the browser.

Was chasing another problem where the focused item wasn’t being scrolled into view, but the $ionicScrollDelegate.resize(); call seems to have solved that.