Skip to content

react-aria list focus conflicting with wrapping code #3785

@mitchellwarr

Description

@mitchellwarr

🐛 Bug Report

Inside the useListBox hook for react-aria, it will focus on elements for you.
However that focusing uses a querySelector that finds [data-key="key"]inside the list area.

This is the line, or one of them:

let element = scrollRef.current.querySelector(`[data-key="${manager.focusedKey}"]`) as HTMLElement;

🤔 Expected Behavior

The hook should find the element to focus on

😯 Current Behavior

If there is any other element inside this area with data-key, then it conflicts and focuses on which ever one it found first inside the DOM element.

💁 Possible Solution

A more specific search to query would be good.

In my case though I am using other react-aria items inside the list area due to keeping it all in one scroll space. But I think I will need to move things and wrap everything in a manual virtualised scroll space to fix my issue

🔦 Context

Just trying to build a list and use data-key, data-label, data-component, data-disabled, and other of these for testing purposes.

🌍 Your Environment

Software Version(s)
react-aria 3.21.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions