Skip to content

Commit ca0072b

Browse files
authored
feat(VirtualScroll): keep focus inside when scrolling quasarframework#7545 (quasarframework#7548)
1 parent 85e75bd commit ca0072b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

ui/src/mixins/virtual-scroll.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,8 @@ export default {
303303
return
304304
}
305305

306+
const hadFocus = rangeChanged === true && typeof scrollEl.contains === 'function' && scrollEl.contains(document.activeElement)
307+
306308
if (rangeChanged === true) {
307309
this.virtualScrollSliceRange = { from, to }
308310
this.virtualScrollPaddingBefore = sumSize(this.virtualScrollSizesAgg, this.virtualScrollSizes, 0, from)
@@ -312,6 +314,10 @@ export default {
312314
this.$nextTick(() => {
313315
if (rangeChanged === true) {
314316
this.__updateVirtualScrollSizes(from)
317+
318+
if (hadFocus === true && scrollEl.contains(document.activeElement) !== true) {
319+
scrollEl.focus()
320+
}
315321
}
316322

317323
const

0 commit comments

Comments
 (0)