You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Press Tab to change the focus to the button (which is offscreen / outside the scroll area.)
Scroll back up, so the button is offscreen but still focused.
Press Space to trigger the button's click event.
Current behavior
The scroll area is scrolled to the button. Depending on browser and screen positioning, scrolling may occur both when the menu is shown and when it's closed.
Expected behavior
A popup or modal that temporarily traps the focus should be self-contained; it should not cause the containing page to scroll.
Context
I encountered this within a tree view's context menus. Focus for SimpleTreeView is (in my opinion) odd: a TreeItem's area within the DOM consists of that item plus all its descendants, so focusing the tree item causes the tree to jump around as the browser tries to make a massive item as focused as possible.
The FocusTrap behavior makes this more obvious / encountered more often, since popping up a context menu for the
See also #36508. If I understand correctly, that refers to behavior while the FocusTrap is active, while this refers to FocusTrap's restoration of focus on exit.
Hi! Sorry, but I fail to see how this should work in your opinion. When I'm focusing the Button in step 2 of your repro, the outer Box is correctly scrolled down. Do you expect the Box to be scrolled up again after opening the Menu?
@michaldudak I apologize; my steps to reproduce were wrong. See the updated steps. If I focus the button, then scroll back up so that the button is offscreen when triggered, I expect the screen to not scroll.
This is more noticeable in my main project - there, I have a right-click context menu on a tree view, and the tree view scrolls when the menu is closed. I expect that not to happen. I tried putting together a test case demonstrating that specific issue but was unsuccessful.
Steps to reproduce
Link to live example: https://stackblitz.com/edit/react-3ufo5w-nfzjjw?file=Demo.tsx,index.tsx
Steps:
Current behavior
The scroll area is scrolled to the button. Depending on browser and screen positioning, scrolling may occur both when the menu is shown and when it's closed.
Expected behavior
A popup or modal that temporarily traps the focus should be self-contained; it should not cause the containing page to scroll.
Context
I encountered this within a tree view's context menus. Focus for SimpleTreeView is (in my opinion) odd: a TreeItem's area within the DOM consists of that item plus all its descendants, so focusing the tree item causes the tree to jump around as the browser tries to make a massive item as focused as possible.
The FocusTrap behavior makes this more obvious / encountered more often, since popping up a context menu for the
See also #36508. If I understand correctly, that refers to behavior while the FocusTrap is active, while this refers to FocusTrap's restoration of focus on exit.
Your environment
npx @mui/envinfo
Search keywords: FocusTrap
The text was updated successfully, but these errors were encountered: