Repository navigation
Commit 8f02c86
This PR cherry-picks changes from the original PR #12629 to branch
24.10.
---
#### Original PR description
> ## Description
>
> When a grid row is larger than the viewport, the `focusin` handler in
`vaadin-grid-scroll-mixin.js` scrolls the focus event target into view
(#9475). If the focused element is inside a nested shadow root, for
example a nested `<vaadin-grid all-rows-visible>` rendered in row
details, `e.target` as seen by the outer grid is retargeted to the
nested component's host element. That host can be thousands of pixels
tall, so aligning its bottom with the footer scrolls the actually
focused cell far out of view. This happens whenever focus is restored
without a preceding mousedown, for example when the browser window
regains focus after switching windows, or when tabbing.
>
> This PR uses `composedPath[0]`, the element that actually received
focus, as the scroll target instead of `e.target`, so the outer grid
keeps the focused nested cell in view instead of jumping. `_onFocusIn`
in the keyboard navigation mixin already resolves the focus target the
same way.
>
> Tests: two new tests with a nested grid in row details. One asserts
that the outer scroll position does not change when the focused nested
cell is already visible, the other asserts that a nested cell outside
the viewport is scrolled into view. Both fail before the change
(scrollTop 170 -> 743; cell 212 px outside the viewport) and pass after
it.
>
> Fixes #10823
>
> ## Type of change
>
> - [x] Bugfix
> - [ ] Feature
>
> ## Checklist
>
> - [x] I have read the contribution guide:
https://vaadin.com/docs/latest/contributing/pr
> - [x] I have added a description following the guideline.
> - [x] The issue is created in the corresponding repository and I have
referenced it.
> - [x] I have added tests to ensure my change is effective and works as
intended.
> - [x] New and existing tests are passing locally with my change.
> - [x] I have performed self-review and corrected misspellings.
> - [ ] I have not completed some of the steps above and my pull request
can be closed immediately.
Co-authored-by: ysnbytrk <ysnbytrk@gmail.com>
1 parent fa53af5 commit 8f02c86
2 files changed
Lines changed: 54 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
131 | | - | |
| 131 | + | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | | - | |
| 141 | + | |
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
138 | 188 | | |
0 commit comments