fix: do not use getCoordinates().inViewPort() to scroll into view#2161
Merged
fix: do not use getCoordinates().inViewPort() to scroll into view#2161
Conversation
Calling getCoordinates().inViewPort() seems to always scroll even if the element is alredy visibile and interactable. This migth cause issue in existing tests. This change partially reverts the previous fix to just use scrollIntoView after viewport check.
caalador
approved these changes
Mar 6, 2026
mcollovati
added a commit
that referenced
this pull request
Mar 6, 2026
…) (CP: 9.6) (#2164) * fix: refactor `autoScrollIntoView()` feature to check `isDisplayed()` or viewport based on the use case (#2158) * fix: replace `isDisplayed()` with viewport check in `autoScrollIntoView()` `doubleClick()`, `click(x,y)` and `contextClick()` threw `MoveTargetOutOfBoundsException` when the target element was inside a scrollable container (e.g. vaadin-grid) but scrolled out of the visible area. The root cause was that `autoScrollIntoView()` used `wrappedElement.isDisplayed()` which returns true for elements that are in the DOM but positioned outside the viewport. Replace the check with `isElementInViewport()`, a JavaScript-based visibility test that verifies the element's bounding rect intersects the viewport and is not clipped by any scrollable ancestor. When the element is outside the viewport, call `scrollIntoView({nearest})` to bring it into view before Selenium's `Actions.moveToElement` reads the element coordinates. Also add a `scrollIntoView(Map)` public overload accepting scroll options. Fixes #2156 * refactor: rename scroll helpers to goal-oriented names in `TestBenchElement` Rename `autoScrollIntoView()` to `ensureVisible()` and `autoScrollIntoViewport()` to `ensureInteractable()` to better communicate intent rather than mechanism. * use Selenium API to scroll into viewport * fix: do not use getCoordinates().inViewPort() to scroll into view (#2161) Calling getCoordinates().inViewPort() seems to always scroll even if the element is alredy visibile and interactable. This migth cause issue in existing tests. This change partially reverts the previous fix to just use scrollIntoView after viewport check.
vaadin-bot
pushed a commit
that referenced
this pull request
Mar 6, 2026
…) (CP: 9.6) (#2164) * fix: refactor `autoScrollIntoView()` feature to check `isDisplayed()` or viewport based on the use case (#2158) * fix: replace `isDisplayed()` with viewport check in `autoScrollIntoView()` `doubleClick()`, `click(x,y)` and `contextClick()` threw `MoveTargetOutOfBoundsException` when the target element was inside a scrollable container (e.g. vaadin-grid) but scrolled out of the visible area. The root cause was that `autoScrollIntoView()` used `wrappedElement.isDisplayed()` which returns true for elements that are in the DOM but positioned outside the viewport. Replace the check with `isElementInViewport()`, a JavaScript-based visibility test that verifies the element's bounding rect intersects the viewport and is not clipped by any scrollable ancestor. When the element is outside the viewport, call `scrollIntoView({nearest})` to bring it into view before Selenium's `Actions.moveToElement` reads the element coordinates. Also add a `scrollIntoView(Map)` public overload accepting scroll options. Fixes #2156 * refactor: rename scroll helpers to goal-oriented names in `TestBenchElement` Rename `autoScrollIntoView()` to `ensureVisible()` and `autoScrollIntoViewport()` to `ensureInteractable()` to better communicate intent rather than mechanism. * use Selenium API to scroll into viewport * fix: do not use getCoordinates().inViewPort() to scroll into view (#2161) Calling getCoordinates().inViewPort() seems to always scroll even if the element is alredy visibile and interactable. This migth cause issue in existing tests. This change partially reverts the previous fix to just use scrollIntoView after viewport check.
mshabarov
pushed a commit
that referenced
this pull request
Mar 9, 2026
…) (CP: 9.6) (#2164) (#2166) * fix: refactor `autoScrollIntoView()` feature to check `isDisplayed()` or viewport based on the use case (#2158) * fix: replace `isDisplayed()` with viewport check in `autoScrollIntoView()` `doubleClick()`, `click(x,y)` and `contextClick()` threw `MoveTargetOutOfBoundsException` when the target element was inside a scrollable container (e.g. vaadin-grid) but scrolled out of the visible area. The root cause was that `autoScrollIntoView()` used `wrappedElement.isDisplayed()` which returns true for elements that are in the DOM but positioned outside the viewport. Replace the check with `isElementInViewport()`, a JavaScript-based visibility test that verifies the element's bounding rect intersects the viewport and is not clipped by any scrollable ancestor. When the element is outside the viewport, call `scrollIntoView({nearest})` to bring it into view before Selenium's `Actions.moveToElement` reads the element coordinates. Also add a `scrollIntoView(Map)` public overload accepting scroll options. Fixes #2156 * refactor: rename scroll helpers to goal-oriented names in `TestBenchElement` Rename `autoScrollIntoView()` to `ensureVisible()` and `autoScrollIntoViewport()` to `ensureInteractable()` to better communicate intent rather than mechanism. * use Selenium API to scroll into viewport * fix: do not use getCoordinates().inViewPort() to scroll into view (#2161) Calling getCoordinates().inViewPort() seems to always scroll even if the element is alredy visibile and interactable. This migth cause issue in existing tests. This change partially reverts the previous fix to just use scrollIntoView after viewport check. Co-authored-by: Marco Collovati <marco@vaadin.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calling getCoordinates().inViewPort() seems to always scroll even if the element is already visible and interactable. This might cause issue in existing tests. This change partially reverts the previous fix to just use scrollIntoView after viewport check.