angular-ui / ui-scroll

Unlimited bidirectional scrolling over a limited element buffer for AngularJS applications
http://angular-ui.github.io/ui-scroll/demo/
MIT License
327 stars 107 forks source link

keyboard scrolling gets stuck when the focused element get destroyed #225

Closed limingli0707 closed 5 years ago

limingli0707 commented 5 years ago

Hi We found the keyboard scrolling doesn't work well the ui-scroll. Basically, once the focused element gets destroyed, the keyboard scrolling doesn't work anymore due to the focus losing. You can reproduce it in the example here: https://rawgit.com/angular-ui/ui-scroll/master/demo/scopeDatasource/scopeDatasource.html You can click on any item, and use command + up/down, it works initially. Then once the element gets destroyed from the DOM, the focus gets lost and the keyboard scrolling doesn't work anymore.

Do you have any thoughts or workaround on this issue? Thanks :)

dhilt commented 5 years ago

If we are speaking of Chrome browser, then it seems the old issue. I opened bug in Chromium times ago, you may find latest updates here: https://bugs.chromium.org/p/chromium/issues/detail?id=493078.

limingli0707 commented 5 years ago

Thanks for your reply. You're right, it seems a browser issue. Firefox is fine and Safari has the same issue.

limingli0707 commented 5 years ago

@dhilt I think I just found a workaround about this. I'm using "tabindex=0" in the ui-scroll-viewport in the HTML in order to make it focusable. Once the dom gets rendered/re-rendered, manually focus on it. (viewportElem.focus()). For now I call the focus function in the datasource get call back in app level, will try to generalize it and create a PR to enhance the ui-scroll lib. Thanks for your help!

dhilt commented 5 years ago

@limingli0707 Perhaps you may create a demo on stackblitz, here's the skeleton with the ui-scroll sources inlined: https://stackblitz.com/edit/angular-ui-scroll-v1-7-4-inline?file=app.js with 1771 lines of es5-generated code. Fork it, make updates and say which lines have been changed... maybe it would be easier.

dhilt commented 2 years ago

Finally the fixed the issue in Chrome v104.