Skip to content

Commit

Permalink
fix(overlay-controller): do not scroll to invoker if it is visible (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
albelop authored Dec 11, 2023
1 parent d997e52 commit c80bca7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/hot-otters-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lion/ui': patch
---

Fix scroll behavior when closing an overlay
2 changes: 1 addition & 1 deletion packages/ui/components/overlays/src/OverlayController.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ export class OverlayController extends EventTarget {

if (this.elementToFocusAfterHide) {
this.elementToFocusAfterHide.focus();
this.elementToFocusAfterHide.scrollIntoView({ block: 'center' });
this.elementToFocusAfterHide.scrollIntoView({ block: 'nearest' });
} else {
/** @type {HTMLElement} */ (this.__activeElementRightBeforeHide).blur();
}
Expand Down

0 comments on commit c80bca7

Please sign in to comment.