mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.10`: - [[FTR] Implement scrollIntoView util (#165080)](https://github.com/elastic/kibana/pull/165080) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Marco Antonio Ghiani","email":"marcoantonio.ghiani01@gmail.com"},"sourceCommit":{"committedDate":"2023-08-29T13:31:27Z","message":"[FTR] Implement scrollIntoView util (#165080)\n\n## 📓 Summary\r\n\r\nBased on the need for [this\r\ntest](https://github.com/elastic/kibana/pull/164493/files#diff-e0bb824023eef20a7b3742da023e25744a6c20406f59ae8400455c579153faeaR262)\r\nto scroll into the element independently of its existence in view, this\r\nPR exposes a new `scrollIntoView` method that replicates the behaviour\r\nof the native [Element\r\n.scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\r\nmethod.\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"56c04d88872bb22d4c941fda6262746e198c5505","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:prev-minor","v7.17.13","v8.11.0"],"number":165080,"url":"https://github.com/elastic/kibana/pull/165080","mergeCommit":{"message":"[FTR] Implement scrollIntoView util (#165080)\n\n## 📓 Summary\r\n\r\nBased on the need for [this\r\ntest](https://github.com/elastic/kibana/pull/164493/files#diff-e0bb824023eef20a7b3742da023e25744a6c20406f59ae8400455c579153faeaR262)\r\nto scroll into the element independently of its existence in view, this\r\nPR exposes a new `scrollIntoView` method that replicates the behaviour\r\nof the native [Element\r\n.scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\r\nmethod.\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"56c04d88872bb22d4c941fda6262746e198c5505"}},"sourceBranch":"main","suggestedTargetBranches":["7.17"],"targetPullRequestStates":[{"branch":"7.17","label":"v7.17.13","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165080","number":165080,"mergeCommit":{"message":"[FTR] Implement scrollIntoView util (#165080)\n\n## 📓 Summary\r\n\r\nBased on the need for [this\r\ntest](https://github.com/elastic/kibana/pull/164493/files#diff-e0bb824023eef20a7b3742da023e25744a6c20406f59ae8400455c579153faeaR262)\r\nto scroll into the element independently of its existence in view, this\r\nPR exposes a new `scrollIntoView` method that replicates the behaviour\r\nof the native [Element\r\n.scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)\r\nmethod.\r\n\r\n---------\r\n\r\nCo-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"56c04d88872bb22d4c941fda6262746e198c5505"}}]}] BACKPORT--> Co-authored-by: Marco Antonio Ghiani <marcoantonio.ghiani01@gmail.com>
This commit is contained in:
parent
879595837b
commit
580501a0ec
1 changed files with 26 additions and 1 deletions
|
@ -730,7 +730,32 @@ export class WebElementWrapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* Scroll the element into view, avoiding the fixed header if necessary
|
||||
* Scroll the element into view
|
||||
*
|
||||
* @param {ScrollIntoViewOptions} scrollIntoViewOptions
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
public scrollIntoView(scrollIntoViewOptions?: ScrollIntoViewOptions) {
|
||||
return this.driver.executeScript<void>(
|
||||
(target: HTMLElement, options: ScrollIntoViewOptions) => target.scrollIntoView(options),
|
||||
this._webElement,
|
||||
scrollIntoViewOptions
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scroll the element into view if it is not already, avoiding the fixed header if necessary
|
||||
* This method is a variation of the scrollIntoView method, where we only scroll into an element
|
||||
* if it is not part of the "scrollable view".
|
||||
* This implies a specific behavior, since the "scrollable view" of the view is identified by
|
||||
* the `document.scrollingElement`, which always results to the html or body tag.
|
||||
*
|
||||
* Use cases:
|
||||
* - An element (a section, a footer) is not visible in the whole page and we need to scroll into it.
|
||||
* - An element is covered by the fixed header and we need to scroll into it ensuring is not covered.
|
||||
*
|
||||
* In case you have a scrollable list smaller that the size of the HTML document and you need
|
||||
* to scroll into an element of that list, prefer using the `.scrollIntoView` method.
|
||||
*
|
||||
* @nonstandard
|
||||
* @return {Promise<void>}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue