Skip to content

FocusScope with contain prevents clicking buttons in scrollable content #9570

@msobiecki

Description

@msobiecki

Provide a general summary of the issue here

When using a scrollable container with an Input at the top and a Button at the bottom, and wrapping the container with FocusScope with the contain prop, it becomes impossible to click the button. The FocusScope continuously scrolls back to the input at the top, keeping it focused and preventing interaction with the button at the bottom.

🤔 Expected Behavior?

  • The button should be clickable.
  • FocusScope should not automatically scroll back to the input or keep it focused when the user tries to interact with other elements in the scrollable area.

😯 Current Behavior

  • Clicking the input at the top of the scrollable list and then trying to click the button at the bottom causes the scroll to jump back to the input.
  • The button cannot be clicked.
  • The input remains focused, and the user cannot unfocus it by clicking elsewhere.

💁 Possible Solution

No response

🔦 Context

This issue affects any scrollable form or panel where users need to interact with multiple elements, such as inputs and buttons, within the same container. In my case, I have a form with a scrollable list of inputs and a submit button at the bottom. When FocusScope with contain is applied, users cannot click the button after focusing an input, making the form unusable.

🖥️ Steps to Reproduce

  1. Open the sandbox: https://codesandbox.io/p/sandbox/objective-leftpad-lq6c43?file=%2Fsrc%2FApp.js%3A33%2C1
  2. Click the input at the top of the scrollable content.
  3. Try clicking the button at the bottom.

Version

react-aria 3.45.0

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

If other, please specify.

No response

What operating system are you using?

MacOS

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions