Keep scroll position when dismissing a notification#3200
Conversation
|
A bit hacky If I'm not mistaken, focus-trap should keep somewhere in memory the list of all tabbable nodes, and correctly handle it on losing one |
c44cb95 to
d3e71c4
Compare
Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: Jan C. Borchardt <925062+jancborchardt@users.noreply.github.com>
d3e71c4 to
9814317
Compare
Adjusted that
Tried, but apparently:
|
Antreesy
left a comment
There was a problem hiding this comment.
Otherwise works just fine. See no clearer way with focus-trap library limitations
| }, | ||
|
|
||
| setItemRef(el, notificationId) { | ||
| this.itemRefs ??= {} |
There was a problem hiding this comment.
let's add following:
- declare it, so we don't introduce any hidden logic;
- convert to Map (slightly better lookup code-wise);
- pave the way for future maintenance and migrations
setup() {
// comment what is this
const itemRefs = new Map()
const setItemRef = (el, id) => el ? itemRefs.set(id, el) : itemRefs.delete(id)
return {
itemRefs,
setItemRef ,
fairUsePolicyNotification,
hasThrottledPushNotifications,
}
},| // Otherwise the header menu focus trap catches the lost focus and jumps | ||
| // it (and the scroll position) to the top of the list. | ||
| const neighbor = this.notifications[index + 1] || this.notifications[index - 1] | ||
| this.itemRefs?.[neighbor?.notificationId]?.focus() |
There was a problem hiding this comment.
| this.itemRefs?.[neighbor?.notificationId]?.focus() | |
| this.itemRefs.get(neighbor?.notificationId)?.focus() |
| t, | ||
|
|
||
| /** | ||
| * Focus the dismiss button, used by the parent to keep focus in the |
There was a problem hiding this comment.
Public method should be declared:
...
emits: ['remove'],
expose: ['focus'],
data() {
...
When clicking the Dismiss button on a notification, the list jumps to the top. This is especially annoying with a long list of notifications.
There should be no jump, only the nice short animation when dismissing the notification.
Seemingly regression from #2959
Before: jumps to top on dismissing notification
Screencast.From.2026-07-15.18-23-54.webm
After: no jump
Screencast.From.2026-07-15.18-19-55.webm
🤖 AI (if applicable)