fix(overlay-controller): do not scroll to invoker if it is visible (#2155)
* fix(overlay-controller): do not scroll to invoker if it is visible on screen When closing an overlay, srollIntoView forced the invoker element to be placed in the middle of the screen. This fix prevents the scroll if the invoker is already visible, but still scrolls it into view if needed. * chore: changeset
This commit is contained in:
parent
d997e5233e
commit
c80bca7c83
2 changed files with 6 additions and 1 deletions
5
.changeset/hot-otters-push.md
Normal file
5
.changeset/hot-otters-push.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/ui': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix scroll behavior when closing an overlay
|
||||||
|
|
@ -933,7 +933,7 @@ export class OverlayController extends EventTarget {
|
||||||
|
|
||||||
if (this.elementToFocusAfterHide) {
|
if (this.elementToFocusAfterHide) {
|
||||||
this.elementToFocusAfterHide.focus();
|
this.elementToFocusAfterHide.focus();
|
||||||
this.elementToFocusAfterHide.scrollIntoView({ block: 'center' });
|
this.elementToFocusAfterHide.scrollIntoView({ block: 'nearest' });
|
||||||
} else {
|
} else {
|
||||||
/** @type {HTMLElement} */ (this.__activeElementRightBeforeHide).blur();
|
/** @type {HTMLElement} */ (this.__activeElementRightBeforeHide).blur();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue